Recommended Posts

I've written a Total Commander packer plugin which is working: now, I can create, open and unpack archives, and of course unpack one or more file(s). The structure for each file is:

[name length][name][creation time][data length][data]

My problem comes with deleting files: I don't know any solution to delete a part of a file, but what if I want it? E.g. I have 3 files in the pack and I want to delete the 2nd file.

Is there any good solution for this problem?

My first thought was that I create a new temp file, open the "old" archive, and write its content to the temp file, of course skip the part I want to delete, then close the files, overwrite the archive with the temp file and of course delete the temp file. But I think it isn't the best solution

Share this post

Link to post

Share on other sites

Not sure if there are any special considerations for Total Commander plugins, but in general the way you would do what you want is exactly what Endurion says you can't. You open the file, move your file pointer to the beginning of the packed file you want to delete, then move the data following the current file up and truncate the file. There is no need to use temporary files.

Share this post

Link to post

Share on other sites

Having to (re)process all of the files is expected for the so-called solid archives -- http://en.wikipedia.org/wiki/Solid_compression (note the "Costs" part).
If a given data compression format isn't using solid compression (it may depend on the settings used when compressing), individual processing is possible (however, the compression ratio is usually worse).
BTW, Total Commander has a pretty good support forum, perhaps you can have a better luck there: http://www.ghisler.ch/board/index.php?language=english