24.01.2012 16:19:58 (8 years ago)

1. Introduced the util::filepath_to_url_format subroutine which will be used to convert filenames to URL style filenames to match the slashes used in the filename regex-es in extrameta keys used to index into extrameta data structures. 2. Fixed bug on windows where metadata.xml specifies filenames as regex with backslash in front of the file extension's period mark: DirectoryPlugin? needed to unregex the filepath before calling fileparse on it, else the escaping backslash would interfere with perl's fileparse routine (only on windows, since backslash also represents a dirsep here). 3. Updated all those perl plugins where the new util::filepath_to_url_format needs to be called so that they use URL style filenames (thereafter regexed) to index into the extrameta data structures.

1 modified


  • main/trunk/greenstone2/perllib/plugins/

    r24951 r24971  
    328328    if ($element eq "FileSet") { 
    329329    foreach my $target (@{$self->{'saved_targets'}}) { 
     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". 
     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 
    330342        my $file_metadata = &extrametautil::getmetadata($self->{'metadataref'}, $target); 
    331343        my $saved_metadata = $self->{'saved_metadata'};