Reduce file size

BlitzPlus Forums/BlitzPlus Programming/Reduce file size

MagicalTux(Posted 2005) [#1]
Hello,

Does anyone knows how to truncate a file ?

I took a function from kernel32.dll :
SetEndOfFile%(hFile%):"SetEndOfFile"

however it doesn't work.

I tried that :
test = OpenFile("i:\test.dat")

SeekFile test, 4096
Notify(SetEndOfFile(test))
CloseFile test


My file "i:\test.dat" is 100000 bytes long, even after running this code (and SetEndOfFile return 0, which means failure).

MSDN says "The SetEndOfFile function sets the physical file size for the specified file to the current position of the file pointer." so I guess the problem is maybe because the OpenFile handler is Blitz-specific.

Anyone knows how to get the real file handler in this case ?


Kevin_(Posted 2005) [#2]
When you say 'truncate a file' to reduce its size, do you mean split the file into 2 at a certain point? If so, why not write a function to read so many bytes from a file then dump it to another file? This will reduce the size of the file but I would advise against it unless you know exactly what data to dump and at what point to split the file.


Grisu(Posted 2005) [#3]
I also don't quite get the point of splitting/truncating a file?

Another way could be to implement ZIP support to your app/game and to create a multiple volume archive. So you get small files.