Show
Ignore:
Timestamp:
24.01.2012 16:19:58 (8 years ago)
Author:
ak19
Message:

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.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/plugins/DirectoryPlugin.pm

    r24951 r24971  
    482482    # filter out any extrametakeys that mention subdirectories and store 
    483483    # for later use (i.e. when that sub-directory is being processed) 
    484     foreach my $ek (@extrametakeys) { 
    485     my ($subdir_re,$extrakey_dir) = &File::Basename::fileparse($ek); 
    486     $extrakey_dir = &util::unregex_filename($extrakey_dir); 
    487  
    488     my $dirsep_re = &util::get_re_dirsep(); 
    489  
    490     my $ek_non_re = &util::unregex_filename($ek); 
     484    foreach my $ek (@extrametakeys) { # where each Extrametakey (which is a filename) is stored as a regex 
     485    my $ek_non_re = &util::unregex_filename($ek); # unregex it. This step is *also* required for the fileparse operation since the file suffix 
     486                                                  # 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();  
    491489    if ($ek_non_re =~ m/$dirsep_re/) { # specifies at least one directory 
    492490        my $md = &extrametautil::getmetadata(\%extrametadata, $ek); 
     
    494492 
    495493        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 format 
     496    # Then need to convert the filename to a regex, no longer to protect windows directory chars \, but for 
     497    # 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_re 
    496500         
    497501        my $subdir_rec = { 're' => $subdir_re, 'md' => $md, 'mf' => $mf };