Changeset 25094 for main/trunk/greenstone2
- Timestamp:
- 2012-02-16T15:10:43+13:00 (12 years ago)
- Location:
- main/trunk/greenstone2/perllib/plugins
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/perllib/plugins/DirectoryPlugin.pm
r24971 r25094 482 482 # filter out any extrametakeys that mention subdirectories and store 483 483 # for later use (i.e. when that sub-directory is being processed) 484 foreach my $ek (@extrametakeys) { # where each Extrametakey (which is a filename) is stored as a regex485 my $ek_non_re = &util::unregex_filename($ek); # unregex it. This step is *also* required for the fileparse operation since the file suffix486 # will be specified as \.txt and we don't want fileparse to split it there making \.txt the "filename"487 my ($subdir_re,$extrakey_dir) = &File::Basename::fileparse($ek_non_re);488 my $dirsep_re = &util::get_re_dirsep();489 if ($ek_non_re =~ m/$dirsep_re/) { # specifies at least one directory484 foreach my $ek (@extrametakeys) { # where each Extrametakey (which is a filename) is stored as a url-style regex 485 486 my ($subdir_re,$extrakey_dir) = &util::url_fileparse($ek); 487 488 if ($extrakey_dir ne "") { 489 # a subdir was specified 490 490 my $md = &extrametautil::getmetadata(\%extrametadata, $ek); 491 491 my $mf = &extrametautil::getmetafile(\%extrametafile, $ek); 492 492 493 493 my $subdir_extrametakeys = $self->{'subdir_extrametakeys'}; 494 495 # Indexing into the extrameta data structures requires the filename's style of slashes to be in URL format496 # Then need to convert the filename to a regex, no longer to protect windows directory chars \, but for497 # protecting special characters like brackets in the filepath such as "C:\Program Files (x86)\Greenstone".498 $subdir_re = &util::filepath_to_url_format($subdir_re); # Possibly not necessary since subdir_re is the last segment of the filepath $ek ####499 $subdir_re = &util::filename_to_regex($subdir_re); # Escape any special chars like brackets and . in subdir_re500 501 494 my $subdir_rec = { 're' => $subdir_re, 'md' => $md, 'mf' => $mf }; 502 495 503 496 # when it's looked up, it must be relative to the base dir 504 497 push(@{$subdir_extrametakeys->{"$local_dirname$extrakey_dir"}},$subdir_rec); 505 #push(@{$subdir_extrametakeys->{"$extrakey_dir"}},$subdir_rec);506 498 } 507 499 } -
main/trunk/greenstone2/perllib/plugins/MetadataXMLPlugin.pm
r24971 r25094 158 158 $self->{'in_filename'} = 0; 159 159 160 161 160 return bless $self, $class; 162 161 } … … 329 328 foreach my $target (@{$self->{'saved_targets'}}) { 330 329 331 # Indexing into the extrameta data structures requires the filename's style of slashes to be in URL 332 # format. But if metadata.xml was user-constructed, its FileName fields (stored in the saved_targets 333 # map) could represent pathnames in Windows format using \ as file separator, instead of pathnames 334 # being in URL format as Greenstone would've generated. Need to convert such filepaths to URL style 335 # paths. Then need convert this to a regex to protect special characters like brackets in the 336 # filepath, such as "C:\Program Files (x86)\Greenstone". 337 338 $target = &util::unregex_filename($target); # filename is a regex, before converting it to URL form, unregex it 339 $target = &util::filepath_to_url_format($target); # convert to URL form 340 $target = &util::filename_to_regex($target); # regex it. Now we have regexed URL form of filename 341 342 my $file_metadata = &extrametautil::getmetadata($self->{'metadataref'}, $target); 330 # FileNames must be regex, but we allow \\ for path separator on windows. convert to / 331 $target = &util::filepath_regex_to_url_format($target); 332 my $file_metadata = &extrametautil::getmetadata($self->{'metadataref'}, $target); 343 333 my $saved_metadata = $self->{'saved_metadata'}; 344 334
Note:
See TracChangeset
for help on using the changeset viewer.