HowTo: Make Zip store files with absolute path? [Solved]

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

HowTo: Make Zip store files with absolute path? [Solved]

#1 Post by sunburnt »

I`ve tried to get Zip to store with absolute paths, but they`re always relative.
With absolute paths from /, you know exactly where the file is going. Period !
With relative paths, you need a script to set the current path and run Zip. ( Sucks...)

Even Tar insists on removing the leading / from the paths it stores.
Tar has the option: " -P --absolute-names " = Don't strip leading `/'s from file names.
But I can`t get it to work anyway... Error: Cannot stat: No such file or directory ( the Tar file ).

Anyone know how to do this?
Last edited by sunburnt on Tue 20 Apr 2010, 13:52, edited 1 time in total.

User avatar
RetroTechGuy
Posts: 2947
Joined: Tue 15 Dec 2009, 17:20
Location: USA

Re: HowTo: Make Zip store files with absolute path?

#2 Post by RetroTechGuy »

sunburnt wrote:I`ve tried to get Zip to store with absolute paths, but they`re always relative.
With absolute paths from /, you know exactly where the file is going. Period !
With relative paths, you need a script to set the current path and run Zip. ( Sucks...)

Even Tar insists on removing the leading / from the paths it stores.
Tar has the option: " -P --absolute-names " = Don't strip leading `/'s from file names.
But I can`t get it to work anyway... Error: Cannot stat: No such file or directory ( the Tar file ).

Anyone know how to do this?
IIRC (long, long ago I used to be one of Info-Zip's beta testers), the preceding "/" was removed because it caused problems, and presented security risks... And for 99.999% of the users, they didn't want the root filesystem pointer stored anyway...

It will store the whole path, other than the "/". Is that not enough?

Look for "directory-traversal security vulnerability" for example:

http://infozip.sourceforge.net/FAQ.html#corruption

User avatar
8-bit
Posts: 3406
Joined: Wed 04 Apr 2007, 03:37
Location: Oregon

#3 Post by 8-bit »

Why not just make a PET out of the program.
There are instructions on how to make one and with a PET, all files and directories are placed where they are supposed to go.

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#4 Post by sunburnt »

Hi RetroTechGuy; As I said, a script is then needed to set the current dir. making the archive utilities not so useful by themselves.

8-bit; It`s just a long standing Q I`ve had about the archive utilities...

User avatar
RetroTechGuy
Posts: 2947
Joined: Tue 15 Dec 2009, 17:20
Location: USA

#5 Post by RetroTechGuy »

sunburnt wrote:Hi RetroTechGuy; As I said, a script is then needed to set the current dir. making the archive utilities not so useful by themselves.
I guess I don't understand what you mean. I just did a quick test, sitting in /root/ (my command prompt "home"):

Code: Select all

zip -r test.zip /mnt/sda3/tmp
Which stored the contents of tmp as "mnt/sda3/tmp/____"

Then I did an unzip as:

Code: Select all

unzip -d / test.zip
Which wrote the contents of test.zip back to the directory /mnt/sda3/tmp/, all while my working directory was /root/.

Code: Select all

unzip -d extraction_directory zipfile.zip
tells unzip to start at "extraction_directory" for its unzip operation.

"unzip" with no parameters will give you a short help page.

Addendum: You could also set up a batch file, making it perform "unzip -d /" on your input your zipfile, or set up an alias:

Code: Select all

alias restore='unzip -d /'
then
restore test.zip
Last edited by RetroTechGuy on Mon 19 Apr 2010, 19:59, edited 1 time in total.

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#6 Post by sunburnt »

Oooppsss, I was looking at the zip -h page, that should help quite a bit...
having to use a special option isn`t "simple friendly", but it does get the job done!
Thanks T.

User avatar
RetroTechGuy
Posts: 2947
Joined: Tue 15 Dec 2009, 17:20
Location: USA

#7 Post by RetroTechGuy »

sunburnt wrote:Oooppsss, I was looking at the zip -h page, that should help quite a bit...
having to use a special option isn`t "simple friendly", but it does get the job done!
Thanks T.
You are most welcome. Personally, I would set up the special alias, knowing that it is your "restore" function.

(for example, I also typically alias/replace "rm" with "remove", and then reset "rm" to "rm -i", to prevent accidents)

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#8 Post by sunburnt »

All good ideas, I only use rm in programs, I use Rox for the manual file operations.

Though I`ve wanted a good Win. file Explorer look-alike for years, none work very well.
ROX works well, that`s the other reason I use it, I want dir. panel at left and file on right side.
It would be nice if there was a slide out extra dir. panel to use when copying and moving.

I should look around again as it`s been a year since I`ve looked at them. Any suggestions?

User avatar
RetroTechGuy
Posts: 2947
Joined: Tue 15 Dec 2009, 17:20
Location: USA

#9 Post by RetroTechGuy »

sunburnt wrote:All good ideas, I only use rm in programs, I use Rox for the manual file operations.

Though I`ve wanted a good Win. file Explorer look-alike for years, none work very well.
ROX works well, that`s the other reason I use it, I want dir. panel at left and file on right side.
It would be nice if there was a slide out extra dir. panel to use when copying and moving.

I should look around again as it`s been a year since I`ve looked at them. Any suggestions?
About the only thing I know off the top of my head is Midnight Commander (a Norton Commander clone).

Haven't used it, however...

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#10 Post by sunburnt »

:lol: I used Norton`s commander for many years in DOS of course.
I`ve tried MC but it`s like NC, 2 file panels, not like Win. Explorer with 1 dir. and 1 file.
It`s close but... There`s 2 Win.Ex. clones I`ve seen, but they just didn`t work as well as ROX.
I`m sure this had a big impression on Barry when he chose the file manager for Puppy.

User avatar
RetroTechGuy
Posts: 2947
Joined: Tue 15 Dec 2009, 17:20
Location: USA

#11 Post by RetroTechGuy »

sunburnt wrote::lol: I used Norton`s commander for many years in DOS of course.
I`ve tried MC but it`s like NC, 2 file panels, not like Win. Explorer with 1 dir. and 1 file.
It`s close but... There`s 2 Win.Ex. clones I`ve seen, but they just didn`t work as well as ROX.
I`m sure this had a big impression on Barry when he chose the file manager for Puppy.
I actually don't use Windows Exploder (nor Internet Exploder). And in those DOS days, wasn't really a fan of NC (I did/do use Qfiler, however).

What I do when I want 2 windows is simply to open 2 windows...dragging from one, to the other. Rox doesn't care if you have the same folder twice. And you simply navigate up and down to drag and drop.

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#12 Post by sunburnt »

Yes... That`s my standard method of copying stuff. I`ll look into it at sometime... Thanks! T.

Post Reply