Jump to content
  • Advertisement
Sign in to follow this  
csisy

TotalCmd - delete file from a custom pack

This topic is 2218 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi,

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 :)

The pack files should be up to 2Gb.

Thanks for your replies, I hope you can help me.

Share this post


Link to post
Share on other sites
Advertisement
That doesn't sound good :( The .zip uses the same solution? Because delete a file from a zip file is really fast. :)

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
Deleting from a .zip is seemingly fast, since the entries are compressed each by it own. Any decent packer will do what you described to remove an entry.

Basically removing a file from a .zip doesn't involve any decompression/recompression at all.

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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!