Read a file to the end, new data is appended, no more is read?
Gary Willoughby
dev at kalekold.net
Thu Jun 20 07:20:31 PDT 2013
auto file = File("file.txt", "r");
char[1024] buffer;
char[] line;
writeln("First Read:");
while ((line = file.rawRead(buffer)) !is null)
{
write(line);
}
Thread.sleep(dur!("seconds")(5));
writeln("Second Read:");
while ((line = file.rawRead(buffer)) !is null)
{
write(line);
}
Tried using the raw access commands still no joy. So i guess it's
still the same issue.
Also tried C stdio too.
char[1024] buffer;
ulong offset;
FILE* file = fopen("text.txt", "r");
printf("First Read:\n");
while(fgets(buffer.ptr, buffer.length, file) !is null)
{
printf("%s", buffer.ptr);
}
offset = ftell(file);
clearerr(file);
Thread.sleep(dur!("seconds")(5));
fseek(file, offset, SEEK_SET);
printf("Second Read:\n");
while(fgets(buffer.ptr, buffer.length, file) !is null)
{
printf("%s", buffer.ptr);
}
fclose(file);
Any ideas?
More information about the Digitalmars-d-learn
mailing list