wolfgangmeyers
July 8th, 2009, 01:40 AM
I found myself in an annoying situation recently. I know from right-clicking on a zip file within a Nautilus window that I can open it with Archive Mounter. I also know that once I do that, I have mounted the zip file, and it is available on my desktop much like a usb device or windows share. This is probably all well known and well documented somewhere. However, I found myself needing to do this from the command line... not so well documented.
After some research I found that Archive Mounter uses gvfs to mount zip files. So I thought maybe there was a command line tool called gvfs. Typing gvfs into the command line and hitting tab a couple of times listed these tools (none of which have man pages):
gvfs-cat gvfs-ls gvfs-mount gvfs-rm
gvfs-copy gvfs-mkdir gvfs-move gvfs-save
gvfs-info gvfs-monitor-dir gvfs-open gvfs-trash
gvfs-less gvfs-monitor-file gvfs-rename gvfs-tree
The most interesting to me here was gvfs-mount, which by naming convention seems to mount things. So I tried using it on zip files -- "Location does not implement mount". I tried appending "zip://" to the beginning -- "Location is unmountable". Then I found somewhere that I could use "archive://" to specify zip file location. So I tried -- archive://path-to-zip file (file not found). Still not giving up, tried mounting again using archive mounter, which had some url encoded characters in the address once I had opened the zip file, %3A (:) and %2F (/). I copy-pasted this as an argument to gvfs-mount, and it worked... gvfs-mount will apparently only mount a zip file when you url encode the path! Given the zip file /foo/bar/foo.zip, the corresponding argument to gvfs-mount:
gvfs-mount archive://file%3A%2F%2F%2Ffoo%2Fbar%2Ffoo.zip
which should be equivalent to:
gvfs-mount archive://file:///foo/bar/foo.zip
but the latter does not work, it will give you a file not found error.
In case anyone else out there has a need to mount zip files from scripts, I hope this helps.
NOTE: once you mount the zip file, the mount point will be <home directory of user>/.gvfs/<name of zip file>/ by default.
After some research I found that Archive Mounter uses gvfs to mount zip files. So I thought maybe there was a command line tool called gvfs. Typing gvfs into the command line and hitting tab a couple of times listed these tools (none of which have man pages):
gvfs-cat gvfs-ls gvfs-mount gvfs-rm
gvfs-copy gvfs-mkdir gvfs-move gvfs-save
gvfs-info gvfs-monitor-dir gvfs-open gvfs-trash
gvfs-less gvfs-monitor-file gvfs-rename gvfs-tree
The most interesting to me here was gvfs-mount, which by naming convention seems to mount things. So I tried using it on zip files -- "Location does not implement mount". I tried appending "zip://" to the beginning -- "Location is unmountable". Then I found somewhere that I could use "archive://" to specify zip file location. So I tried -- archive://path-to-zip file (file not found). Still not giving up, tried mounting again using archive mounter, which had some url encoded characters in the address once I had opened the zip file, %3A (:) and %2F (/). I copy-pasted this as an argument to gvfs-mount, and it worked... gvfs-mount will apparently only mount a zip file when you url encode the path! Given the zip file /foo/bar/foo.zip, the corresponding argument to gvfs-mount:
gvfs-mount archive://file%3A%2F%2F%2Ffoo%2Fbar%2Ffoo.zip
which should be equivalent to:
gvfs-mount archive://file:///foo/bar/foo.zip
but the latter does not work, it will give you a file not found error.
In case anyone else out there has a need to mount zip files from scripts, I hope this helps.
NOTE: once you mount the zip file, the mount point will be <home directory of user>/.gvfs/<name of zip file>/ by default.