Win\Path - Filename and Pathname Manipulation ============================================= File: Win\Path - Update: 1.00 Author: J.G.Harston - Date: 18-Jan-2008 The Win/Path library has functions for manipulating various filenames and pathnames. DEFFNf_root(path$) - finding path root ====================================== FNf_root() extracts the root directory from the supplied path. You can't just look for a colon specifying a drive, as the program may have been run with a Uniform Naming Convention path (eg "\\mainserver\docs\april.txt"). Also, the path may be surrounded by quotes, which also have to be taken care of. FNf_root() will return as per the following examples: FNf_root("C:\Documents and Settings\jgh\Admin") -> "C:" FNf_root("H:\Apps") -> "H:" FNf_root("\\datastore\Tools\Admin") -> "\\datastore" FNf_root("X:") -> "X:" You can then do, for example: PROCcopyfiles(root$+"\Data","D:\Backup","*.*") DEFFNf_leaf(path$) - Finding leafname ===================================== FNf_leaf() will scan through a fully-qualified pathname to find just the leafname - the final part of the path. For example: FNf_leaf("H:\Apps\Admin\Startup.exe") returns "Startup.exe". DEFFNf_path(path$) - Finding pathname ===================================== FNf_path() will remove the leafname, keeping just the pathname. For example: FNf_path("H:\Apps\Admin\Startup.exe") returns "H:\Apps\Admin\" This lets you use code such as: IF out$="" THEN out$=FNf_path(in$)+"output.txt" DEFFNf_noext(path$) - Removing extension ======================================== FNf_noext() will remove an extension from a pathname. Note that you cannot just remove the last four characters, as the extension is not guaranteed to be four characters (eg, ".c"), nor can you simply search for a ".", as the path may have multiple "."s in it (eg "C:\index.dat\20090721\thumb.db" or even "Version1.00\data.file.txt"). You can then use this to do, for example: PROCBMP_toGIF(bmpfile$,FNf_noext(bmpfile$)+".gif") Note that filenames similar to ".htaccess" are actually all extension and no name. DEFFNf_ext(path$) - Finding extension ===================================== FNf_ext() will scan through a fully-qualified pathname to find the extension. As with FNf_noext(), you cannot just use the last four characters. You can then use this to do, for example: runapp$=FNMime_Type(FNf_ext(file$)) DEFFNf_fullpath(path$, file$) - Ensure full absolute path ========================================================= It is good practice for programs to access files via fully-specified paths, yet it can also be useful for programs to be able to access certain files relative to some path, such as the directory the program is running in. FNf_fullpath() will take a path and a filename and return the full path of a relative filename. It functions as in the following examples. FNf_fullpath("C:\EARS","DATA") -> "C:\EARS\DATA" FNf_fullpath("C:\EARS","A:\INCOMING") -> "A:\INCOMING" FNf_fullpath("C:\EARS","\\system\backup") -> "\\system\backup" Version History =============== 1.00 18-Jan-2008 Initial version. 1.01 27-Feb-2008 Functions put within _ naming convention.