CBAIS::Path::FileLocator - file locator
use CBAIS::Path::FileLocator;
my ($fl) = new CBAIS::Path::FileLocator();
my ($file) = $fl->getSpecificFile('conf', 'Class.cf');
print "Found file $file\n";
The CBAIS::Path::FileLocator object is used for finding operating system/processor dependent, and host specific versions of files in directory trees. It uses the file naming conventions shown below.
<project>/<directory_root>/[<os><ps>]<os_version><ps><architecture>/<filename>.<specifier>
<specifier> = <fq_hostname>|<hostname>|<domain_name>|<alias>
use CBAIS::Util::Utils; use CBAIS::Path::FileLocator;
my ($specifier) = new CBAIS::Path::FileLocator();
my ($file) = $specifier->getSpecificFile('conf/Classes', 'Class.cf');
if ($file eq '/cbais/default/conf/Classes/Linux::2.2.16-22::i686/Class.cf') { print "Found file for Linux 2.2.16-22 and i686\n";
}
$file = $specifier->getHostSpecificFile("copy/Class", '/etc/passwd');
if ($file eq "/cbais/default/copy/Class/etc/passwd.avalon") { print "Found file for host avalon\n";
}
my ($sunos_specifier) = new CBAIS::Path::FileLocator(OS => 'Sunos', ARCHITECTURE => 'sun4u', GENERIC_ARCHITECTURE => 'sun4', OS_RELEASE => '5.5', MAJOR_OS_RELEASE => '5.x', PROJECTS => ['project1', 'default', ]);
$sunos_specifier->getHostArchSpecificFile("pkg/local", 'apache.tgz'); if ($file eq "test_data/default/pkg/local/Linux::2.2.16-22::i686/apache.tgz.avalon") { print "Found very very specific file\n";
}
The FileLocator methods are listed below.
new()
hash_ref}disableOSName()
setProjects()
project ..setArchitecture()
architecturesetOS()
ossetOSRelease()
os releasetoString()
getSpecificFile()
root, fileLocate a specific file. The file is specific as far as operating system type and release, and processor type information (i.e. CBAIS dir tree structure) is concerned. File name suffixes are not applied. If no specific files are found (and the file does not exist), 0 is returned, otherwise the most specific file found is returned.
getHostSpecificFile()
root, fileLocate a host specific file. Only file suffix specifiers are checked in this method. The architecture and OS version specifiers are ignored.
getHostArchSpecificFile()
root, fileLocate a host specific file. OS, OS version, architecture and file suffix specifiers are checked in this method.