Deleting from a data file

Blitz3D Forums/Blitz3D Programming/Deleting from a data file

Storm8191(Posted 2005) [#1]
I don't know if this has been asked on these forums before but I still need help with it. For all my projects, I have a list of functions, and which file they're in, in the projects 'base' file. I use this to help find functions when there are errors. The problem with this is that it takes a long time to create and alot of work to update. I'm trying to write a program to automate this process, which would modify the project's base source file.

My problem is, I'd like to do a complete erase and replace of the list, as it's really big, because major changes to the project may make the list smaller. Unfortunately, I can find no way to physically delete data from an open file with Blitz commands. Blitz allows over-writing of data in a text file by using write operations on an "OpenFile()" file, but I see no way to reduce the size of a file.

Does anyone have any solutions to this, or will I have to resort to a work-around? I could use writefile and re-write the whole source file, then copy the result over the real source file, but I'd like to find an easier way.

Thanks for any information you can provide on this.


Ross C(Posted 2005) [#2]
I think the only way is to rewrite the file i'm afraid...


DH(Posted 2005) [#3]
Agreed


big10p(Posted 2005) [#4]
Yep. I'm not aware of any language that allows files to be reduced in size without completely re-writing the file - it's not just a blitz thing. If you think about how data is stored on disk, it makes sense.

You can append to an existing file, but if you do this often with large files, the file (sectors) could become fragmented across the disk. This could potentially affect loading times adversely - as well as giving your HD a good workout.