Changeset 24932 for main/trunk/greenstone2/perllib/util.pm
- Timestamp:
- 2012-01-10T16:18:19+13:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/perllib/util.pm
r24874 r24932 845 845 $filename =~ s@\(@\\(@g; # escape brackets 846 846 $filename =~ s@\)@\\)@g; # escape brackets 847 $filename =~ s@\[@\\[@g; # escape brackets 848 $filename =~ s@\]@\\]@g; # escape brackets 847 849 848 850 return $filename; … … 857 859 $filename =~ s@\\\(@(@g; # remove RE syntax for ( => "\(" turns into "(" 858 860 $filename =~ s@\\\)@)@g; # remove RE syntax for ) => "\)" turns into ")" 861 $filename =~ s@\\\[@[@g; # remove RE syntax for [ => "\[" turns into "[" 862 $filename =~ s@\\\]@]@g; # remove RE syntax for ] => "\]" turns into "]" 859 863 return $filename; 860 864 } … … 1032 1036 } 1033 1037 1034 1038 # If filename is relative to within_dir, returns the relative path of filename to that directory 1039 # with slashes in the filename returned as they were in the original (absolute) filename. 1035 1040 sub filename_within_directory 1036 1041 { … … 1049 1054 return $filename; 1050 1055 } 1056 1057 # If filename is relative to within_dir, returns the relative path of filename to that directory in URL format. 1058 # Filename and within_dir can be any type of slashes, but will be compared as URLs (i.e. unix-style slashes). 1059 # The subpath returned will also be a URL type filename. 1060 sub filename_within_directory_url_format 1061 { 1062 my ($filename,$within_dir) = @_; 1063 1064 # convert parameters only to / slashes if Windows 1065 1066 my $filename_urlformat = $filename; 1067 my $within_dir_urlformat = $within_dir; 1068 1069 if ($ENV{'GSDLOS'} =~ /^windows$/i) { 1070 # Only need to worry about Windows, as Unix style directories already in url-format 1071 # Convert Windows style \ => / 1072 $filename_urlformat =~ s@\\@/@g; 1073 $within_dir_urlformat =~ s@\\@/@g; 1074 } 1075 1076 #if ($within_dir_urlformat !~ m/\/$/) { 1077 # make sure directory ends with a slash 1078 #$within_dir_urlformat .= "/"; 1079 #} 1080 1081 my $within_dir_urlformat_re = &filename_to_regex($within_dir_urlformat); # escape any special RE characters, such as brackets 1082 1083 #print STDERR "@@@@@ $filename_urlformat =~ $within_dir_urlformat_re\n"; 1084 1085 # dir prefix may or may not end with a slash (this is discarded when extracting the sub-filepath) 1086 if ($filename_urlformat =~ m/^$within_dir_urlformat_re(?:\/)*(.*)$/) { 1087 $filename_urlformat = $1; 1088 } 1089 1090 return $filename_urlformat; 1091 } 1092 1051 1093 1052 1094 sub filename_within_collection
Note:
See TracChangeset
for help on using the changeset viewer.