Jeff Massung wrote:
I'm still new to Rev, but in other languages this is dead simple:
void truncate_huge_file(const char* filename)
{
FILE* fp = fopen(filename,"wb");
char bytes[200];
size_t new_len;
// move to the end of the file, read 200 bytes
fseek(fp, -200, SEEK_END);
fread(bytes, 1, 200, fp);
// .. TODO: scan for end of line, repeat as needed
// .. TODO: seek SEEK_CUR past what should still be there
new_len = ftell(fp);
// nuke everything else at the end of the file
trunctate(fp, new_len);
fclose(fp);
}
Done.
Now, maybe this isn't as easy in Rev as it is in C and *many* other
languages. But it should be [if it isn't].
That looks similar to what I posted here on the 9th:
open file tFile for update
seek relative -1000 in file tFile
repeat
read from file tFile until cr
if it is not empty then
put it after tBuffer
else
delete last line of tBuffer
write tBuffer to file tFile
end if
end repeat
close file tFile
Does that not do what you need?
--
Richard Gaskin
Fourth World
Rev training and consulting: http://www.fourthworld.com
Webzine for Rev developers: http://www.revjournal.com
revJournal blog: http://revjournal.com/blog.irv
_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution