Changeset 15165


Ignore:
Timestamp:
2008-04-02T18:11:24+13:00 (16 years ago)
Author:
ak19
Message:

Modified soft_link method to take an extra parameter ensure_paths_absolute, and if set it will check whether absolute paths are given for src and dest else make them absolute paths

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gsdl/trunk/perllib/util.pm

    r15113 r15165  
    395395# make soft link to file if supported by OS, otherwise copy file
    396396sub soft_link {
    397     my ($src, $dest) = @_;
     397    my ($src, $dest, $ensure_paths_absolute) = @_;
    398398
    399399    # remove trailing slashes from source and destination files
    400400    $src =~ s/[\\\/]+$//;
    401401    $dest =~ s/[\\\/]+$//;
     402
     403    # Ensure file paths are absolute IF requested to do so
     404    # Soft_linking didn't work for relative paths
     405    if(defined $ensure_paths_absolute && $ensure_paths_absolute) {
     406    # We need to ensure that the src file is the absolute path
     407    # See http://perldoc.perl.org/File/Spec.html
     408    if(!File::Spec->file_name_is_absolute( $src ))  { # it's relative
     409        $src = File::Spec->rel2abs($src); # make absolute
     410    }
     411    # Might as well ensure that the destination file's absolute path is used
     412    if(!File::Spec->file_name_is_absolute( $dest )) {
     413        $dest = File::Spec->rel2abs($dest); # make absolute
     414    }
     415    }
    402416
    403417    # a few sanity checks
Note: See TracChangeset for help on using the changeset viewer.