Update of /cvsroot/sandweb/sandweb/lib/SandWeb
In directory usw-pr-cvs1:/tmp/cvs-serv31315/lib/SandWeb
Modified Files:
File.pm
Log Message:
made mime.types location and filename configurable in sandweb.cfg
Index: File.pm
===================================================================
RCS file: /cvsroot/sandweb/sandweb/lib/SandWeb/File.pm,v
retrieving revision 1.25
retrieving revision 1.26
diff -U2 -r1.25 -r1.26
--- File.pm 2001/12/20 23:31:37 1.25
+++ File.pm 2001/12/21 01:12:47 1.26
@@ -17,4 +17,5 @@
my $filename = $args{'filename'};
my $log_obj = $args{'log_obj'};
+ my $config = $args{'config_obj'};
my $location = $args{'location'};
my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
@@ -26,4 +27,5 @@
'location' => $location,
'log_obj' => $log_obj,
+ 'config_obj' => $config,
'mode' => $mode,
'uid' => $uid,
@@ -86,8 +88,16 @@
my $location = $self->{'location'};
my $filename = $self->{'filename'};
+ my $log = $self->{'log_obj'};
+ my $config = $self->{'config_obj'};
+
+ my $mime_file = $config->{'webserver'}->{'mime-types_file'};
+ my $mime_location = $config->{'webserver'}->{'mime-types_location'};
my $mime_type = _get_mime_type(
'location' => "$location",
'filename' => "$filename",
+ 'mime_file' => "$mime_file",
+ 'mime_location' => "$mime_location",
+ 'log_obj' => "$log",
);
@@ -113,4 +123,8 @@
my $filename = $self->{'filename'};
my $log = $self->{'log_obj'};
+ my $config = $self->{'config_obj'};
+
+ my $mime_location = $config->{'webserver'}->{'mime-types_location'};
+ my $mime_file = $config->{'webserver'}->{'mime-types_file'};
$log->debug("downloading file : $location/$filename");
@@ -120,4 +134,7 @@
'location' => "$location",
'filename' => "$filename",
+ 'mime_file' => "$mime_file",
+ 'mime_location' => "$mime_location",
+ 'log_obj' => "$log",
);
$log->debug("MIME type looks like : $mime_type");
@@ -212,9 +229,9 @@
my @fromfile = _do_file_read();
+
_do_file_write(
'filename' => $filename,
'location' => $location,
'contents' => "@fromfile",
- 'log_obj' => $log,
);
@@ -246,9 +263,6 @@
'location' => "$location",
'filename' => "$filename",
- 'log_obj' => $log,
);
-
-
return $contents;
}
@@ -288,11 +302,19 @@
my $location = $args{'location'};
my $filename = $args{'filename'};
+ my $log = $args{'log_obj'};
+ my $mime_location = $args{'mime_location'};
+ my $mime_file = $args{'mime_file'};
my @file_split = split(/\./, $filename);
my $file_extension = $file_split[$#file_split];
my $mime_type;
- open FILE,"< /usr/local/apache/conf/mime.types";
- my @mimes = <FILE>;
- close FILE;
+
+ my $mime_output = _do_file_read(
+ 'location' => "$mime_location",
+ 'filename' => "$mime_file",
+ );
+
+ my @mimes = split(/ /, $mime_output);
+
foreach my $entry (@mimes) {
unless ( $entry =~ /^#/) {
|