From 59fffb9c146e55911fab8a01a62c65b82a1d43da Mon Sep 17 00:00:00 2001 From: dakkar Date: Mon, 13 Aug 2007 15:33:52 +0000 Subject: =?UTF-8?q?argh!=20Cwd::abs=5Fpath=20fa=20gi=C3=A0=20tutto...?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: svn://luxion/repos/WebCoso/trunk@273 fcb26f47-9200-0410-b104-b98ab5b095f3 --- lib/Path/ResolveSymlinks.pm | 39 --------------------------------------- t/prs-01.t | 35 ----------------------------------- 2 files changed, 74 deletions(-) delete mode 100644 lib/Path/ResolveSymlinks.pm delete mode 100644 t/prs-01.t diff --git a/lib/Path/ResolveSymlinks.pm b/lib/Path/ResolveSymlinks.pm deleted file mode 100644 index 695122a..0000000 --- a/lib/Path/ResolveSymlinks.pm +++ /dev/null @@ -1,39 +0,0 @@ -package Path::ResolveSymlinks; -use strict; -use warnings; -use Cwd 'abs_path'; -use Path::Class; -use Carp; - -sub resolve_symlinks { - my ($name)=@_; - - my ($dir,$file); - if (-d $name) { - $dir=dir($name); - } - elsif (-f $name) { - $file=file($name); - $dir=$file->parent; - $file=$file->basename; - } - else { - croak "$name is neither a file nor a directory"; - } - - $dir=dir(abs_path($dir));warn "dir: $dir\n"; - return $dir unless defined $file; - - $file=$dir->file($file);warn "file: $file\n"; - return $file unless -l $file; - - my $dest=file(readlink $file);warn "dest: $dest\n"; - if ($dest->is_absolute) { - return resolve_symlinks($dest); - } - else { - return resolve_symlinks($dir->file($dest)); - } -} - -1; diff --git a/t/prs-01.t b/t/prs-01.t deleted file mode 100644 index 5aaf93c..0000000 --- a/t/prs-01.t +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/perl -use strict; -use warnings; -use Test::More qw(no_plan); -use Path::Class; - -BEGIN { use_ok('Path::ResolveSymlinks') or die } - -my $base=dir('','tmp','prs-test'); - -$base->mkpath; - -END { $base->rmtree } - -$base->subdir('real')->mkpath; -symlink $base->subdir('real'),$base->file('linked'); - -my $TEST_CONTENT=<<'EOF'; -test content -EOF - -{ my $fh=$base->file('real','data-real.txt')->openw; - print $fh $TEST_CONTENT -}; - -symlink $base->file('real','data-real.txt'),$base->file('real','data.txt'); - -symlink 'data-real.txt',$base->file('real','data-rel.txt'); - -is(Path::ResolveSymlinks::resolve_symlinks($base->file('linked','data.txt')), - $base->file('real','data-real.txt'), - 'resolved abs ok'); -is(Path::ResolveSymlinks::resolve_symlinks($base->file('linked','data-rel.txt')), - $base->file('real','data-real.txt'), - 'resolved rel ok'); -- cgit v1.2.3