diff options
author | Reinhard Kotucha <reinhard.kotucha@web.de> | 2008-01-20 22:12:10 +0000 |
---|---|---|
committer | Reinhard Kotucha <reinhard.kotucha@web.de> | 2008-01-20 22:12:10 +0000 |
commit | 7236dbfeb785534f8aede7f8b3c93b8a2d1f263b (patch) | |
tree | d6925517b6b07c149a7c06018f3ee2114b34bdb6 | |
parent | 895be1e59f1fdb9adca204e7f96a7ad281892b21 (diff) |
TLUtils.pm: dirname, basename: replace '\' by '/' when on Windows.
git-svn-id: svn://tug.org/texlive/trunk@6337 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r-- | Master/tlpkg/TeXLive/TLUtils.pm | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/Master/tlpkg/TeXLive/TLUtils.pm b/Master/tlpkg/TeXLive/TLUtils.pm index ac661311c73..be36b02ef70 100644 --- a/Master/tlpkg/TeXLive/TLUtils.pm +++ b/Master/tlpkg/TeXLive/TLUtils.pm @@ -270,7 +270,7 @@ sub getenv { my $var=$ENV{"$envvar"}; return 0 unless (defined $var); if (&win32) { - $var=~s@\\@/@g; # change \ -> / (required by Perl) + $var=~s!\\!/!g; # change \ -> / (required by Perl) } return "$var"; } @@ -360,8 +360,12 @@ Return C<$path> with its trailing C</component> removed. =cut sub dirname { - if ($_[0] =~ m!/!) { # dirname("foo/bar/baz") -> "foo/bar" - $_[0] =~ m!(.*)/.*!; + my $path=shift; + if (win32) { + $path=~s!\\!/!g; + } + if ($path=~m!/!) { # dirname("foo/bar/baz") -> "foo/bar" + $path=~m!(.*)/.*!; return $1; } else { # dirname("ignore") -> "." return "."; @@ -376,10 +380,14 @@ Return C<$path> with any leading directory components removed. =cut sub basename { - if ($_[0] =~ m!/!) { # basename("foo/bar") -> "bar" - $_[0] =~ m!.*/(.*)!; + my $path=shift; + if (win32) { + $path=~s!\\!/!g; + } + if ($path=~m!/!) { # basename("foo/bar") -> "bar" + $path=~m!.*/(.*)!; return $1; - } else { # basename("ignore") -> "ignore" + } else { # basename("ignore") -> "ignore" return $_[0]; } } @@ -394,8 +402,12 @@ Return both C<dirname> and C<basename>. Example: =cut sub dirname_and_basename { - $_[0]=~/(.*)\/(.*)/; - return ("$1", "$2"); + my $path=shift; + if (win32) { + $path=~s!\\!/!g; + } + $path=~/(.*)\/(.*)/; + return ("$1", "$2"); } =pod |