Changeset 27394

Show
Ignore:
Timestamp:
23.05.2013 13:01:25 (6 years ago)
Author:
jmt12
Message:

Replaced hardcoded -e (which should have been a -d anyway) with FileUtils::directoryExists() call and replaced hardcoded pregs to remove extra and trailing slashes in path with call to FileUtils::sanitizePath() (which does the same thing, but in a way that is aware of protocol prefixes)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/inexport.pm

    r27352 r27394  
    241241    # fill in the default import and archives directories if none 
    242242    # were supplied, turn all \ into / and remove trailing / 
    243     $importdir = &FileUtils::filenameConcatenate($ENV{'GSDLCOLLECTDIR'}, "import") if $importdir eq ""; 
    244     # @todo &FileUtils::sanitizePath($importdir) [jmt12] 
    245     $importdir =~ s/[\\\/]+/\//g; 
    246     $importdir =~ s/\/$//; 
    247     if (!-e $importdir) { 
    248     &gsprintf($out, "{import.no_import_dir}\n\n", $importdir); 
    249     die "\n"; 
     243    if ($importdir eq "") 
     244    { 
     245      $importdir = &FileUtils::filenameConcatenate($ENV{'GSDLCOLLECTDIR'}, "import"); 
     246    } 
     247    else 
     248    { 
     249      # Don't do this - it kills protocol prefixes 
     250      #$importdir =~ s/[\\\/]+/\//g; 
     251      #$importdir =~ s/\/$//; 
     252      # Do this instead 
     253      &FileUtils::sanitizePath($importdir); 
     254    } 
     255    if (!&FileUtils::directoryExists($importdir)) 
     256    { 
     257      &gsprintf($out, "{import.no_import_dir}\n\n", $importdir); 
     258      die "\n"; 
    250259    } 
    251260    $self->{'importdir'} = $importdir;