From: Rob H. <for...@us...> - 2001-11-24 11:09:34
|
Update of /cvsroot/sandweb/sandweb/lib/SandWeb In directory usw-pr-cvs1:/tmp/cvs-serv31763/lib/SandWeb Modified Files: File.pm Log Message: added methods for : create_file, create_folder, remove_file, remove_folder, rename, copy tested all functions and added documentation. browse_menu UI is going to need some rethinking; there's no way a checked file can get passed right now, since all file operations are HREFs rather than part of an HTML form. I'm going to leave this unhooked from the frontend (browse_menu) for now. I put stubs in place on the frontend; just simple templates. Stubs are good. Index: File.pm =================================================================== RCS file: /cvsroot/sandweb/sandweb/lib/SandWeb/File.pm,v retrieving revision 1.12 retrieving revision 1.13 diff -U2 -r1.12 -r1.13 --- File.pm 2001/11/22 08:44:32 1.12 +++ File.pm 2001/11/24 11:09:31 1.13 @@ -88,3 +88,76 @@ } +sub create_file { + my $self = shift; + my $location = $self->{'location'}; + my $filename = $self->{'filename'}; + + open (FILE, ">$location/$filename"); + my $return = close FILE; + + return $return; +} + +sub create_folder { + my $self = shift; + my $location = $self->{'location'}; + my $filename = $self->{'filename'}; + + my $return = mkdir( "$location/$filename" ); + + return $return; +} + +sub remove_file { + my $self = shift; + my $location = $self->{'location'}; + my $filename = $self->{'filename'}; + + my $return = unlink("$location/$filename" ); + + return $return; +} + +sub remove_folder { + my $self = shift; + my $location = $self->{'location'}; + my $filename = $self->{'filename'}; + + my $return = rmdir("$location/$filename" ); + + return $return; +} + +sub copy { + my $self = shift; + my %args = @_; + my $location = $self->{'location'}; + my $filename = $self->{'filename'}; + my $tofile = $args{'tofile'}; + + open ( FROM_FILE, "< $location/$filename" ); + my @fromfile = (<FROM_FILE>); + close FROM_FILE; + + open ( TO_FILE, "> $tofile" ); + foreach my $line (@fromfile) { + print TO_FILE "$line"; + } + close TO_FILE; + + return $return; +} + +sub rename { + my $self = shift; + my %args = @_; + my $location = $self->{'location'}; + my $filename = $self->{'filename'}; + my $tofile = $args{'tofile'}; + + my $return = rename( "$location/$filename", "$tofile" ); + + return $return; +} + 1; |