source: trunk/gsdl/cgi-bin/download@ 8322

Last change on this file since 8322 was 8096, checked in by davidb, 20 years ago

Special case code added for a collection name of "/tmp" (or any collection
name beginning with a slash). This is interpreted to mean the top level
gsdl folder, not within 'collect'.

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 1.1 KB
Line 
1#!/usr/bin/perl -w
2
3use gsdlCGI;
4
5sub main
6{
7 my $gsdl_cgi = new gsdlCGI("+cmdline");
8
9
10 my $gsdlhome = $gsdl_cgi->get_config_info("gsdlhome");
11
12 my $col = $gsdl_cgi->clean_param("c");
13 if (!defined $col) {
14 $gsdl_cgi->generate_error("No collection specified.");
15 }
16
17 my $dir = $gsdl_cgi->clean_param("dir");
18 $dir = "" if ((!defined $dir) || ($dir eq "."));
19
20 if ($col =~ m/^\//) {
21 # leading / at start denotes special "cols" such as "/tmp"
22 $gsdl_cgi->checked_chdir("$gsdlhome");
23 $col =~ s/^\///;
24 }
25 else {
26 $gsdl_cgi->checked_chdir("$gsdlhome/collect");
27 }
28
29 # Change this to Java zip??
30 my $zip_cmd = "zip -r $col.zip $col/$dir";
31 $gsdl_cgi->unix_cmd($zip_cmd);
32
33
34 my $pipe_cmd = "cat $col.zip"; # Unix specific
35
36 if (open(PIN,"$pipe_cmd |")) {
37 binmode(PIN);
38
39 my $buf;
40 my $num_bytes = 0;
41
42 print "Content-type:application/zip\n\n";
43
44 while (read(PIN,$buf,1024)>0) {
45 print STDOUT $buf;
46 $num_bytes += length($buf);
47 }
48
49 close(PIN);
50
51 my $status = $?;
52 }
53 else {
54 $gsdl_cgi->generate_error("Unable to pipe input from: $pipe_cmd");
55 }
56
57 unlink "$col.zip";
58}
59
60&main();
61
Note: See TracBrowser for help on using the repository browser.