Thanks a ton for the examples in the product. That'll make writing this a lot easier.
When I said "only append", I'm not aware of a CreateFile flag that allows me to insert into the middle (or at the beginning) of a file. I can only overwrite.
For example, if a 4 byte file on disk has
byte[0] = 'A'
byte[1] = 'B'
byte[2] = 'C'
byte[3] = 'D'
and I open the file for writing, seek to position 0, and then write out 'x', the file looks like this
byte[0] = 'x'
byte[1] = 'B'
byte[2] = 'C'
byte[3] = 'D'
When I need to prepend data to a file, I have to account for the overwrite by looping through the file (backwards), reading a chunk at the old position and writing it at the new position. Then I've got "free space" at the beginning of the file to overwrite.
If I'm wrong about that, and there is a way to insert at the beginning of a file using the Win32 API, then please tell me! I've been following this file pattern in my code for years.
When I said "only append", I'm not aware of a CreateFile flag that allows me to insert into the middle (or at the beginning) of a file. I can only overwrite.
For example, if a 4 byte file on disk has
byte[0] = 'A'
byte[1] = 'B'
byte[2] = 'C'
byte[3] = 'D'
and I open the file for writing, seek to position 0, and then write out 'x', the file looks like this
byte[0] = 'x'
byte[1] = 'B'
byte[2] = 'C'
byte[3] = 'D'
When I need to prepend data to a file, I have to account for the overwrite by looping through the file (backwards), reading a chunk at the old position and writing it at the new position. Then I've got "free space" at the beginning of the file to overwrite.
If I'm wrong about that, and there is a way to insert at the beginning of a file using the Win32 API, then please tell me! I've been following this file pattern in my code for years.
- Kevin