-
Notifications
You must be signed in to change notification settings - Fork 31
It is possible to access and traverse the files inside a zip archive as though it were a mounted file system. If you are editing a directory, and goo.zip is one of the files, type g, and you will see a page that says Zip Archive at the top, with links to the files and directories at the top of the zip archive. From there you can descend into subdirectories, or extract files. Edbrowse never pulls the entire archive into a buffer, so the archive can be huge.
This is not native; you need three plugins and a supporting script. I wrote the script in bash, though you could use python or perl or whatever floats your boat. Below are the plugins, followed by the script, which should be placed in your bin.
plugin {
type = zip
desc = zip archive
suffix = zip
program = ebunzip %i
from_file
outtype = H
}
plugin {
type = zip
desc = zip show directory
protocol = zipxd
program = ebunzip %i
outtype = H
}
plugin {
type = zip
desc = zip extract file
protocol = zipx
program = ebunzip %i
outtype = T
}
And now for the bash script that performs the magic.
#!/bin/bash
if [ $# != 1 ]
then
echo "usage ebunzip zipfile[path]"
exit 1;
fi
# This script assumes none of the pathnames in the zip archive
# contain the " or ; characters.
# zip file and path
zf="$1"
path=""
if [[ "$zf" =~ @:@ ]]
then
path=${zf/*@:@/}
zf=${zf/@:@*/}
# check here for file extract
if [[ "$zf" =~ zipx: ]]
then
zf=${zf/zipx:??/}
unzip -p "$zf" "$path"
exit 0
fi
zf=${zf/zipxd:??/}
fi
echo "<body>Zip Archive"
if [ -z "$path" ]
then
# root directory
unzip -t "$zf" |
sort |
sed -e '/testing:/!d' -e 's/^.*testing: *//' -e 's/ *OK$//' \
-e '/\/./d' \
-e "s;.*;://$zf@:@&\">&</a>;" \
-e '/\/">/s/^/d/' \
-e 's;^;<br><a href="zipx;'
else
unzip -t "$zf" |
sort |
sed -e '/testing:/!d' -e 's/^.*testing: *//' -e 's/ *OK$//' \
-e "s;^$path;@:@&;" \
-e '/^@:@/!d' -e 's/^@:@//' \
-e "s;^$path;;" \
-e '/^$/d' \
-e '/\/./d' \
-e "s;.*;://$zf@:@$path&\">&</a>;" \
-e '/\/">/s/^/d/' \
-e 's;^;<br><a href="zipx;'
fi
echo "</body>"
Similar scripts and plugins could be written for cpio, tar, and other archival formats.