Expand/Shrink

get_file_name

Definition: string filename = get_file_name(string path)
Description: Extract the file name portion of a filepath.

path: the filepath from which to extract information.

Returns a string, the file name part of path.
pwa/p2js: Supported (after all it is only a bit of text extraction).
Comments: Uses get_proper_path(), so on Windows if the file exists the case of the result will match the actual file.

Both forwardslash ('/') and backslash ('\\') are handled for all platforms.
Auxillary function: string {name, path} = get_file_name_and_path(string filepath, bool dropslash=true)

Convenience function that avoids having to invoke both get_file_name() and get_file_path(), with the same parameter.
Note there is also a get_file_path_and_name() function which returns the same values the other way round, for when that seems more natural, besides having both means one less thing for the compiler to get all snooty and uppity about.
Example:
?get_file_name("C:/Program Files (x86)/Phix/builtins/vm/papnd.e")   -- displays "pApnd.e"
Implementation: See builtins\file_utils.e (an autoinclude) for details of the actual implementation.
See Also: get_proper_path, get_file_base, get_file_extension
Expand/Shrink