- my ($modestring, $ur, $uw, $ux, $gr, $gw, $gx, $or, $ow, $ox);
- my $mode = shift;
-
- $ur = ($mode & 0400) ? "r" : "-"; # User Read
- $uw = ($mode & 0200) ? "w" : "-"; # User Write
- $ux = ($mode & 0100) ? "x" : "-"; # User eXecute
- $gr = ($mode & 0040) ? "r" : "-"; # Group Read
- $gw = ($mode & 0020) ? "w" : "-"; # Group Write
- $gx = ($mode & 0010) ? "x" : "-"; # Group eXecute
- $or = ($mode & 0004) ? "r" : "-"; # Other Read
- $ow = ($mode & 0002) ? "w" : "-"; # Other Write
- $ox = ($mode & 0001) ? "x" : "-"; # Other eXecute
-
- # build a readable mode string (rwxrwxrwx)
- return $ur . $uw . $ux . $gr . $gw . $gx . $or . $ow . $ox;
+ my $path = shift;
+ $path =~ tr!\\!/!;
+
+ unless($path eq "/")
+ {
+ $path = substr($path,0,-1) if($path =~ m!/$!);
+ $path = substr($path,rindex($path,"/")+1);
+ }
+
+ return $path;