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.50 -r1.133.2.51 --- openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl 10 Sep 2014 18:17:20 -0000 1.133.2.50 +++ openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl 28 Sep 2014 15:55:41 -0000 1.133.2.51 @@ -10,6 +10,43 @@ namespace eval util {} +ad_proc util::zip_file { + -source:required + -destination:required +} { + Create a zip file. + If source is a directory, archive will contain all files into directory without the trailing directory itself. +} { + set cmd [list exec] + switch $::tcl_platform(platform) { + windows { + lappend cmd cmd.exe /c + } + default { + lappend cmd bash -c + } + } + if {[file isfile $source]} { + set filename [file tail $source] + set in_path [file dirname $source] + } else { + set filename "." + set in_path $source + } + # To avoid having the full path of the file included in the archive, + # we must first cd to the source directory. zip doesn't have an option + # to do this without building a little script... + set zip_cmd [list] + lappend zip_cmd "cd $in_path" + lappend zip_cmd "zip -r \"${destination}\" \"${filename}\"" + set zip_cmd [join $zip_cmd " && "] + + lappend cmd $zip_cmd + + # create the archive + {*}$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. Index: openacs-4/packages/file-storage/www/download-zip.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/www/download-zip.tcl,v diff -u -r1.6.6.3 -r1.6.6.4 --- openacs-4/packages/file-storage/www/download-zip.tcl 5 Aug 2014 17:46:33 -0000 1.6.6.3 +++ openacs-4/packages/file-storage/www/download-zip.tcl 28 Sep 2014 15:55:41 -0000 1.6.6.4 @@ -40,12 +40,9 @@ set out_file [file join ${out_path} ${download_name}] -# get the archive command -set cmd "zip -r \"$out_file\" ." - # create the archive with_catch errmsg { - exec bash -c "cd $in_path; $cmd; cd -" + util::zip_file -source $in_path -destination $out_file } { # some day we'll do something useful here file delete -force $in_path