Index: openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl,v diff -u -r1.133.2.52 -r1.133.2.53 --- openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl 28 Sep 2014 16:06:35 -0000 1.133.2.52 +++ openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl 29 Sep 2014 11:49:06 -0000 1.133.2.53 @@ -15,20 +15,20 @@ -destination:required } { Create a zip file. - If source is a directory, archive will contain all files into directory without the trailing directory itself. + + @param source is the content to be zipped. If it is a directory, archive will + contain all files into directory without the trailing directory itself. + + @param destination is the name of the created file } { set zip [util::which zip] if {$zip eq ""} { error "zip command not found on the system." } set cmd [list exec] switch $::tcl_platform(platform) { - windows { - lappend cmd cmd.exe /c - } - default { - lappend cmd bash -c - } + windows {lappend cmd cmd.exe /c} + default {lappend cmd bash -c} } if {[file isfile $source]} { set filename [file tail $source] @@ -51,6 +51,25 @@ {*}$cmd } +ad_proc util::unzip_file { + -source:required + -destination:required + -overwrite:boolean +} { + @param source must be the name of a valid zip file to be decompressed + + @param destination must be the name of a valid directory to contain decompressed files +} { + set unzip [util::which unzip] + if {$unzip eq ""} {error "unzip command not found on the system."} + # -n means we don't overwrite existing files + set cmd [list exec $unzip] + if {$overwrite_p} {lappend cmd -o + } else {lappend cmd -n} + lappend cmd $source -d $destination + {*}$cmd +} + # Let's define the nsv arrays out here, so we can call nsv_exists # on their keys without checking to see if it already exists. # we create the array by setting a bogus key.