NAME
Meta::Utils::File::Path - module to handle path names.
COPYRIGHT
Copyright (C) 2001 Mark Veltzer; All rights reserved.
LICENSE
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
DETAILS
MANIFEST: Path.pm PROJECT: meta
SYNOPSIS
package foo;
use Meta::Utils::File::Path qw();
my($full)=Meta::Utils::File::Path::add_path("/usr/bin:/bin","/sbin:/usr/sbin",":");
DESCRIPTION
This package is intended to help you handle paths. For example - remove automounted parts from your path, get cannonic paths, get absolute paths, get paths with as few ".." as possible, reduce paths to a minimum etc...
EXPORTS
add_path($$$)
add_path_min($$$)
min_path($$)
resolve_nodie($$$)
resolve($$$)
append($$$)
remove_path($$$)
remove_nonexist($$)
FUNCTION DOCUMENTATION
- add_path($$$)
-
This functions receives: 1. A first path component. 2. A second path component. 3. A separator used for those paths. And returns a path which is the catenation of those two paths. If one of them is nothing then the extra separator will be ommited.
- add_path_min($$$)
-
This method does exactly as add_path except it also minimizes the path of the catenation if indeed catenation takes place (if no catenation takes place the path is kept the same as the first or second element which must be already minimized if you with the result ot be minimized).
- min_path($$)
-
This function receives: 0. A string which is a path name. 1. A separator. This function assumes that the string is a path name with the second argument is the separator and returns a string which is in effect the same path but has no two entries which are the same. The algorithm is to construct a new path and remember the old parts as not to repeat them.
- resolve_nodie($$$)
-
This method receives a path and a file and returns the resolution of them: meaning the abosolute file name of the first file in the path that matches the file.
- resolve($$$)
-
This method is the same as resolve_nodie expect it dies if it cannot find the file.
- append($$$)
-
This will append a suffix to the path. This means all elements in the path.
- remove_path($$$)
-
This method reveices a path (and a separator) and a path name. The method assumes that file is in one of the elements in the path and returns the relative part of the file name.
- remove_nonexist($$)
-
This method return a path which is like the original given to it except it removes the parts of the path which are not real directories.
BUGS
None.
AUTHOR
Mark Veltzer <mark2776@yahoo.com>
HISTORY
start of revision info end of revision info
SEE ALSO
Nothing.
TODO
Nothing.