Welcome, Guest. Please login or register.

Author Topic: Adding to a growing file in the filesystem with C...  (Read 2462 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline Cymric

  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 1031
    • Show all replies
Re: Adding to a growing file in the filesystem with C...
« on: April 12, 2005, 09:50:56 PM »
I don't really see the problem---why don't you leave the file open for writing? The FS won't close it on its own, after all: it will wait patiently for you to close it.

The fragmentation is nearly unavoidable. Perhaps you can counter it to some extent by reserving space in the form of a really big file, sufficiently sized to contain the complete log, and then gradually overwrite it, making sure you pad the stuff you write out to the exact same size as the original dummy file. But that is a wild guess at best, relying on inner workings of the FS you should really not be relying on. Why is a non-fragmented file so important anyway? The FS will handle the fragmentation transparently when you read the file back into memory.

Methinks you are trying to solve a problem which really is not a problem :-).
Some people say that cats are sneaky, evil and cruel. True, and they have many other fine qualities as well.
 

Offline Cymric

  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 1031
    • Show all replies
Re: Adding to a growing file in the filesystem with C...
« Reply #1 on: April 14, 2005, 07:57:30 PM »
Seems like you want an Open() with MODE_OLDFILE, and then a Seek() to the end, and hey presto, you can begin Write()ing ;-).
Some people say that cats are sneaky, evil and cruel. True, and they have many other fine qualities as well.