Fix #403: Handle unsearchable file.
This commit is contained in:
parent
e8a8766c2f
commit
2dbda715b1
30
src/ctags.d
30
src/ctags.d
|
@ -33,11 +33,37 @@ void printCtags(File output, string[] fileNames)
|
||||||
foreach (fileName; fileNames)
|
foreach (fileName; fileNames)
|
||||||
{
|
{
|
||||||
RollbackAllocator rba;
|
RollbackAllocator rba;
|
||||||
File f = fileName == "stdin" ? std.stdio.stdin : File(fileName);
|
|
||||||
|
ubyte[] bytes;
|
||||||
|
|
||||||
|
if (fileName == "stdin")
|
||||||
|
{
|
||||||
|
File f = std.stdio.stdin;
|
||||||
|
immutable stepSize = 4096;
|
||||||
|
ubyte[] buffer = uninitializedArray!(ubyte[])(stepSize);
|
||||||
|
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
auto dataRead = f.rawRead(buffer[$ - stepSize .. $]);
|
||||||
|
if (dataRead.length < stepSize)
|
||||||
|
{
|
||||||
|
bytes = buffer[0 .. $ - (stepSize - dataRead.length)];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
buffer.length += stepSize;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
File f = File(fileName);
|
||||||
|
|
||||||
if (f.size == 0)
|
if (f.size == 0)
|
||||||
continue;
|
continue;
|
||||||
auto bytes = uninitializedArray!(ubyte[])(to!size_t(f.size));
|
|
||||||
|
bytes = uninitializedArray!(ubyte[])(to!size_t(f.size));
|
||||||
f.rawRead(bytes);
|
f.rawRead(bytes);
|
||||||
|
}
|
||||||
|
|
||||||
auto tokens = getTokensForParser(bytes, config, &cache);
|
auto tokens = getTokensForParser(bytes, config, &cache);
|
||||||
Module m = parseModule(tokens.array, fileName, &rba, &doNothing);
|
Module m = parseModule(tokens.array, fileName, &rba, &doNothing);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue