--- loncom/publisher/loncfile.pm 2003/08/04 17:45:06 1.37 +++ loncom/publisher/loncfile.pm 2003/08/04 20:08:23 1.38 @@ -9,7 +9,7 @@ # and displays a page showing the results of the action. # # -# $Id: loncfile.pm,v 1.37 2003/08/04 17:45:06 www Exp $ +# $Id: loncfile.pm,v 1.38 2003/08/04 20:08:23 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -819,27 +819,13 @@ sub Rename2 { " new file ".$newfile."\n"); &Debug($request, "Target is: ".$directory.'/'. $newfile); - - if(-e $oldfile) { - my $dest; - - if ($oldfile =~ m|/$|) { - #renaming a dir - $oldfile =~ s|/$||; - $dest=$directory; - $dest=~s|(/)([^/]*)$|$1|; - $dest.='/'.$newfile; - } else { - $dest=$directory.'/'.$newfile; - } - - unless(rename($oldfile,$dest)) { + if (-e $oldfile) { + unless (rename($oldfile,$newfile)) { $request->print('Error: '.$!.''); return 0; - } else {} + } } else { - $request->print("

No such file: /home".$user.'/public_html'. - $oldfile.'

'); + $request->print("

No such file: ".&display($oldfile).'

'); return 0; } return 1; @@ -1047,13 +1033,7 @@ sub phasetwo { if(!&Rename2($r, $uname, $dir, $fn, $ENV{'form.newfilename'})) { return; } - # Prepend the directory to the new name to form the basis of the - # url of the new resource. - # - #renaming a dir - #remove last element for current dir - if ($fn =~ m|/$|) { $dir =~ s|/[^/]*$||; } - $dest = $dir."/".$ENV{'form.newfilename'}; + $dest = &url($ENV{'form.newfilename'}); } } elsif ($ENV{'form.action'} eq 'delete') { if(!&Delete2($r, $uname, $ENV{'form.newfilename'})) { @@ -1076,38 +1056,13 @@ sub phasetwo { } } elsif ($ENV{'form.action'} eq 'newdir') { - # - # Since the newfilename form field is construction space - # relative, ew need to prepend the current path; now in $fn. - # - my $newdir= $fn.$ENV{'form.newfilename'}; + my $newdir= $ENV{'form.newfilename'}; if(!&NewDir2($r, $uname, $newdir)) { return; } $dest = $newdir."/" } - # - # Substitute for priv for the first home in $dir to get our - # construction space path. - # - $dest=&MakeFinalUrl($r,$dest); - - $r->print('

Done

'); -} - -sub MakeFinalUrl { - my($r,$dest)=@_; - &Debug($r, "Final url is: $dest"); - $dest =~ s|/home/|/priv/|; - $dest =~ s|/public_html||; - - my $base = &File::Basename::basename($dest); - my $dpath= &File::Basename::dirname($dest); - if ($base eq '.') { $base=''; } - $dest = &HTML::Entities::encode($dpath.'/'.$base); - - &Debug($r, "Final url after rewrite: $dest"); - return $dest; + $r->print('

Done

'); } sub handler {