Changeset 18337
- Timestamp:
- 2009-01-08T18:32:09+13:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gsdl/trunk/perllib/util.pm
r18329 r18337 995 995 } 996 996 997 # returns the given filename converted using either URL encoding or 998 # base64 encoding, as specified by $rename_method 997 # Returns the given filename converted using either URL encoding or base64 998 # encoding, as specified by $rename_method. If the given filename has no suffix 999 # (if it is just the tailname), then $no_suffix should be some defined value. 999 1000 sub rename_file { 1000 my ($filename, $rename_method ) = @_;1001 1002 if(!$filename) { # for example,empty string1001 my ($filename, $rename_method, $no_suffix) = @_; 1002 1003 if(!$filename) { # undefined or empty string 1003 1004 return $filename; 1004 1005 } 1005 1006 my ($tailname,$dirname,$suffix) = File::Basename::fileparse($filename, "\\.[^\\.]+\$"); 1006 1007 # Replace spaces with underscore. 1008 # Do this first else it can go wrong below when getting tailname 1009 $filename =~ s/ /_/g; 1010 1011 # Should we do this???? 1012 # DM safing would have replaced underscores with character entity _ 1013 $filename =~ s/&\#095;/_/g; 1014 1015 my ($tailname,$dirname,$suffix); 1016 if($no_suffix) { # given a tailname, no suffix 1017 $suffix = ""; 1018 ($tailname,$dirname) = File::Basename::fileparse($filename); 1019 } 1020 else { 1021 ($tailname,$dirname,$suffix) = File::Basename::fileparse($filename, "\\.(?:[^\\.]+?)\$"); 1022 } 1007 1023 1008 1024 if (!$rename_method) { … … 1010 1026 # Debugging information 1011 1027 my ($cpackage,$cfilename,$cline,$csubr,$chas_args,$cwantarray) = caller(1); 1012 print STDERR "Calling method ;$cfilename:$cline $cpackage->$csubr\n";1028 print STDERR "Calling method: $cfilename:$cline $cpackage->$csubr\n"; 1013 1029 } 1014 1030
Note:
See TracChangeset
for help on using the changeset viewer.