Jump to content

  • Log In with Google      Sign In   
  • Create Account

TotalCmd - delete file from a custom pack


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 csisy   Members   -  Reputation: 256

Like
0Likes
Like

Posted 25 August 2012 - 02:04 PM

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.
sorry for my bad english :)

Sponsor:

#2 Endurion   Crossbones+   -  Reputation: 3694

Like
1Likes
Like

Posted 25 August 2012 - 11:22 PM

Well, it may not feel nice, but that's the way to do it. If you're hoping for some sort of delete part of file and have the rest data get moved upwards, there is no such thing.
Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

#3 csisy   Members   -  Reputation: 256

Like
0Likes
Like

Posted 26 August 2012 - 02:17 AM

That doesn't sound good :( The .zip uses the same solution? Because delete a file from a zip file is really fast. :)
sorry for my bad english :)

#4 krippy2k8   Members   -  Reputation: 646

Like
1Likes
Like

Posted 26 August 2012 - 03:41 AM

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.

#5 Endurion   Crossbones+   -  Reputation: 3694

Like
1Likes
Like

Posted 26 August 2012 - 07:23 AM

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.
Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

#6 csisy   Members   -  Reputation: 256

Like
0Likes
Like

Posted 26 August 2012 - 09:39 AM

Thanks for your replies :)
sorry for my bad english :)

#7 Matt-D   Crossbones+   -  Reputation: 1469

Like
1Likes
Like

Posted 26 August 2012 - 05:56 PM

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




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS