File::RelDir - Perl module that returns relative path between two directories
use File::RelDir; $ref=File::RelDir->New("/tmp/here"); $relative_path = $ref->Path("/tmp/there"); #returns "../there" $ref=File::RelDir->New('d:\users\me\excel'); $relative_path = $ref->Path('d:\users\me\word'); #returns '../word' $relative_path = File::RelDir->Diff('d:\users\me\excel', e:\users\me\word'); #returns undef $relative_path = File::RelDir->Diff('d:\users\me\excel', d:\users\me\word'); #returns '../word'
The File:RelDir provides a mechanism to determine the relative path between two directory structures. It honours case sensitivity unless one (or both) the paths compared appears to be a windows path, when it becomes case insensitive.
It returns undef when no similarity between the directories supplied is determined.
The New method establishes a reference based on the directory name provided.
The Path method returns the relative path to the directory name supplied, or undef in the event the two directories are not compatible.
The case of the relative path is retained (wether a windows style case insensitive directory comparison was performed). The directory seperator will be forward slash based (/), unless a backslash (\) based directory path is provided to the New call.
The Diff method provides a simpler method of achieving the same end for the occasional relative path, use New and Path if you have multiple calls on the same base directory.
Dave Roberts <email@example.com>
You can send bug reports and suggestions for improvements on this module to me at firstname.lastname@example.org. However, I can't promise to offer any other support for this package.
This module is Copyright © 2012 Dave Roberts. All rights reserved.
This script is free software; you can redistribute it and/or modify it under the same terms as Perl itself. This script 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. The copyright holder of this script can not be held liable for any general, special, incidental or consequential damages arising out of the use of the script.