Changeset 20413


Ignore:
Timestamp:
2009-08-28T09:57:18+12:00 (15 years ago)
Author:
kjdon
Message:

modifed rename_file to make a bit more efficient when rename_method is none.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gsdl/trunk/perllib/util.pm

    r19762 r20413  
    10301030# Returns the given filename converted using either URL encoding or base64
    10311031# encoding, as specified by $rename_method. If the given filename has no suffix
    1032 # (if it is just the tailname), then $no_suffix should be some defined value.
     1032# (if it is just the tailname), then $no_suffix should be some defined value.
     1033# rename_method can be url, none, base64
    10331034sub rename_file {
    10341035    my ($filename, $rename_method, $no_suffix)  = @_;
     
    10361037    if(!$filename) { # undefined or empty string
    10371038    return $filename;
     1039    }
     1040
     1041    if (!$rename_method) {
     1042    print STDERR "WARNING: no file renaming method specified. Defaulting to using URL encoding...\n";
     1043    # Debugging information
     1044    my ($cpackage,$cfilename,$cline,$csubr,$chas_args,$cwantarray) = caller(1);
     1045    print STDERR "Called from method: $cfilename:$cline $cpackage->$csubr\n";
     1046    $rename_method = "url";
     1047    } elsif($rename_method eq "none") {
     1048    return $filename; # would have already been renamed
    10381049    }
    10391050
     
    10511062    $suffix = "" if !$suffix;
    10521063
    1053     if (!$rename_method) {
    1054     print STDERR "WARNING: no file renaming method specified. Defaulting to using URL encoding...\n";
    1055     # Debugging information
    1056     my ($cpackage,$cfilename,$cline,$csubr,$chas_args,$cwantarray) = caller(1);
    1057     print STDERR "Calling method: $cfilename:$cline $cpackage->$csubr\n";
    1058     } elsif($rename_method eq "none") {
    1059     return $filename; # would have already been renamed
    1060     }
    1061 
    1062     if (!$rename_method || $rename_method eq "url") {
     1064    if ($rename_method eq "url") {
    10631065    $tailname = &unicode::url_encode($tailname);
    10641066    }
Note: See TracChangeset for help on using the changeset viewer.