NAME File.Basename - A library that provides unix-like tools 'dirname' and 'basename' SYNOPSIS JSAN.use('File.Basename'); // or // Class Example var path = "/testing/path/file.ext"; var file = new File.Basename(path); // basename = 'file.ext' var basename = file.basename(); var dirname = file.dirname(); // tell user document.writeln("basename is '" + basename + "'"); // dump platform document.writeln("Parsed " + file.path() + " as platform " + file.platform_str()); DESCRIPTION This library provides tools to take a filepath and pull the directory name and filename out of it. This is much like the perl module 'File::Basename' or the unix shell tools of 'basename' and 'dirname'. This type of tool can be useful if you need to process full paths on the server in request but want to display only filenames to the user. Constructor var file = new File.Basename(path, platform); Create a new "File.Basename" object. * path File path to process * platform *optional* A 'File.Basename' platform constant, this tells the object how to process the filepath it was given. If this is not passed the object will try to guess based upon the user agent string. If this is not available then it will default to UNIX. For the platform constants see the section Constants below. Class Properties VERSION File.Basename.VERSION Current library version Methods basename() file.basename(); Returns the basename of the filepath passed to the constructor. Returns empty string if no basename exists. dirname() file.dirname Returns the directory name of the path. Under Windows this can/will return the drive letter as well. Constants * File.Basename.WIN Indicates the desire for Windows pathname processing. (backslashes) * File.Basename.MAC Indicates the desire for Mac (same as UNIX today) pathname processing. (forward slashes) * File.Basename.UNIX Indicates object is current processing pathnames for *NIX systems (forward slashes). SEE ALSO nothing at this time. TODO This will not work with several multibyte character sets like 'shift_jis'. It will work fine with UTF8. Need to add a test for non-english UTF8 characters and such... Need to add support to pull extension off Need to add functional support. (basename(filepath) returns basename) AUTHOR Lee Carmichael COPYRIGHT Copyright (c) 2005 Lee Carmichael. All rights reserved. This module is free software; you can redistribute it and/or modify it under the terms of the Artistic license.