Changeset 30352

Show
Ignore:
Timestamp:
16.12.2015 15:44:15 (4 years ago)
Author:
jmt12
Message:

Adding in a function to test whether a File driver has a certain function. Also adding in support for an optional driver funtion to determine if a certain path is special (and so shouldn't be changed) or not

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • gs2-extensions/parallel-building/trunk/src/perllib/FileUtils.pm

    r30287 r30352  
    7777} 
    7878## callFunction() 
     79 
     80 
     81## @function _hasFunction() 
     82# 
     83sub _hasFunction 
     84{ 
     85    my $driver_name = shift(@_); 
     86    my $function_name = shift(@_); 
     87    # Need to look within fileutils directory 
     88    my $package_name = 'FileUtils::' . $driver_name; 
     89    # Try to load the requested infodb type 
     90    if (!&_loadDriver($package_name)) 
     91    { 
     92    &printError('Failed to load requested file protocol driver: ' . $package_name, 1); 
     93    } 
     94    # Then make call to the newly created package 
     95    no strict; 
     96    # Check if the function call exists 
     97    my $symbol = qualify($function_name, $package_name); 
     98    return defined &{$symbol}; 
     99} 
     100## _hasFunction() 
     101 
    79102 
    80103## @function _prettyPrint() 
     
    433456      $first = 0; 
    434457      $dirsofar .= $dirname; 
    435       next if $dirname =~ /^(|[a-z]:)$/i; 
     458      next if $dirname =~ /^(|[a-z]+:)$/i; 
     459      # we can't create some directories (drivers specific) 
     460      if (&isSpecialDirectory($dirsofar)) { 
     461      next; 
     462      } 
    436463      if (!&directoryExists($dirsofar)) 
    437464      { 
     
    600627} 
    601628## isHDFS() 
     629 
     630 
     631## @function isSpecialDirectory() 
     632# 
     633sub isSpecialDirectory 
     634{ 
     635    my $path = shift(@_); 
     636    my $driver = &FileUtils::_determineDriver($path); 
     637    my $result = 0; # not special 
     638    if (&FileUtils::_hasFunction($driver, 'isSpecialDirectory')) 
     639    { 
     640    $result = &FileUtils::_callFunction($driver, 'isSpecialDirectory', $path); 
     641    } 
     642    return $result; 
     643} 
     644## isSpecialDirectory() 
     645 
    602646 
    603647## @function isSymbolicLink()