Update of /cvsroot/sandweb/sandweb/lib/SandWeb
In directory usw-pr-cvs1:/tmp/cvs-serv7863
Modified Files:
File.pm
Log Message:
created file_write and file_read methods
these are public methods that will handle file reads and
creation, and set the debug and error logs accordingly.
Index: File.pm
===================================================================
RCS file: /cvsroot/sandweb/sandweb/lib/SandWeb/File.pm,v
retrieving revision 1.17
retrieving revision 1.18
diff -U2 -r1.17 -r1.18
--- File.pm 2001/12/18 20:24:12 1.17
+++ File.pm 2001/12/20 02:26:24 1.18
@@ -7,5 +7,6 @@
# standard modules
#
-# this one is for the get_age() method
+# POSIX is for the get_age() method
+
use POSIX qw(strftime);
@@ -23,4 +24,5 @@
'filename' => $filename,
'location' => $location,
+ 'log_obj' => $log,
'mode' => $mode,
'uid' => $uid,
@@ -81,5 +83,4 @@
sub get_size {
my $self = shift;
-
return $self->{'size'};
}
@@ -97,7 +98,13 @@
my $location = $self->{'location'};
my $filename = $self->{'filename'};
+ my $log = $self->{'log_obj'};
- open (FILE, ">$location/$filename");
- my $return = close FILE;
+
+ my $file = SandWeb::File->new(
+ 'location' => "$location",
+ 'filename' => "$filename",
+ );
+
+ $file->file_write( 'contents' => "test" );
return $return;
@@ -108,4 +115,5 @@
my $location = $self->{'location'};
my $filename = $self->{'filename'};
+ my $log = $self->{'log_obj'};
my $return = mkdir( "$location/$filename", "0336" );
@@ -118,4 +126,5 @@
my $location = $self->{'location'};
my $filename = $self->{'filename'};
+ my $log = $self->{'log_obj'};
my $return = unlink("$location/$filename" );
@@ -128,4 +137,5 @@
my $location = $self->{'location'};
my $filename = $self->{'filename'};
+ my $log = $self->{'log_obj'};
my $return = rmdir("$location/$filename" );
@@ -139,4 +149,5 @@
my $location = $self->{'location'};
my $filename = $self->{'filename'};
+ my $log = $self->{'log_obj'};
my $tofile = $args{'tofile'};
@@ -159,8 +170,38 @@
my $location = $self->{'location'};
my $filename = $self->{'filename'};
+ my $log = $self->{'log_obj'};
my $tofile = $args{'tofile'};
my $return = rename( "$location/$filename", "$tofile" );
+ return $return;
+}
+
+sub file_read {
+ my $self = shift;
+ my %args = @_;
+ my $location = $self->{'location'};
+ my $filename = $self->{'filename'};
+ my $log = $self->{'log_obj'};
+
+ open (FILE, "< $location/$filename");
+ my $contents = <FILE>;
+ close FILE;
+
+ return $contents;
+}
+
+sub file_write {
+ my $self = shift;
+ my %args = @_;
+
+ my $location = $self->{'location'};
+ my $filename = $self->{'filename'};
+
+ my $contents = $args{'contents'};
+
+ open (FILE, ">$location/$filename");
+ print FILE $contents;
+ my $return = close FILE;
return $return;
}
|