1 # By Brandon S. Allbery
3 # This library is no longer being maintained, and is included for backward
4 # compatibility with Perl 4 programs which may require it.
5 # This legacy library is deprecated and will be removed in a future
7 # In particular, this should not be used as an example of modern Perl
8 # programming techniques.
10 # Suggested alternative: Cwd
13 # Usage: $cwd = &getcwd;
17 local($dotdots, $cwd, @pst, @cst, $dir, @tst);
19 unless (@cst = stat('.'))
27 $dotdots .= '/' if $dotdots;
30 unless (opendir(getcwd'PARENT, $dotdots)) #'))
32 warn "opendir($dotdots): $!";
35 unless (@cst = stat($dotdots))
37 warn "stat($dotdots): $!";
38 closedir(getcwd'PARENT); #');
41 if ($pst[$[] == $cst[$[] && $pst[$[ + 1] == $cst[$[ + 1])
49 unless (defined ($dir = readdir(getcwd'PARENT))) #'))
51 warn "readdir($dotdots): $!";
52 closedir(getcwd'PARENT); #');
55 unless (@tst = lstat("$dotdots/$dir"))
57 # warn "lstat($dotdots/$dir): $!";
58 # closedir(getcwd'PARENT); #');
62 while ($dir eq '.' || $dir eq '..' || $tst[$[] != $pst[$[] ||
63 $tst[$[ + 1] != $pst[$[ + 1]);
66 closedir(getcwd'PARENT); #');