Author(s): Daniel Cabeza, Angel Fernandez Pineda.
Version: 1.11#222 (2004/5/24, 13:8:7 CEST)
Version of last change: 1.3#51 (1999/9/9, 16:28:44 MEST)
This library provides some small utilities to handle file name syntax.
filenames
)filenames
)This predicate will extract the last item (usually the file name) from a given path.
The first argument must be instantiated to a string or atom. Whenever the first argument is an atom, the second argument will be an atom. Whenever the first argument is a string, the second argument will be a string.
This predicate will fail under any of the following conditions:
Those are the most usual usages of no_path_file_name/2:
?- no_path_file_name_("/home/nexusV/somefile.txt",K). K = "somefile.txt" ? yes ?- no_path_file_name('/home/nexusV/somefile.txt',K). K = 'somefile.txt' ? yes ?-
Usage: no_path_file_name(Path, FileName)
FileName
is the file corresponding to the given Path
.
Path
is an atom or a string
(filenames:atom_or_str/1
)
FileName
is an atom or a string
(filenames:atom_or_str/1
)
This predicate may be used in two ways:
?- file_name_extension(File,mywork,'.txt'). File = 'mywork.txt' ? yes ?-
?- file_name_extension('mywork.txt',A,B). A = mywork, B = '.txt' ? yes ?-
Any other usage of file_name_extension/3 will cause the predicate to fail. Notice that valid arguments are accepted both as atoms or strings.
Usage: file_name_extension(FileName, BaseName, Extension)
FileName
into its BaseName
and Extension
.
FileName
is an atom or a string
(filenames:atom_or_str/1
)
BaseName
is an atom or a string
(filenames:atom_or_str/1
)
Extension
is an atom or a string
(filenames:atom_or_str/1
)
basename(FileName, BaseName)
BaseName
is FileName
without extension. Equivalent to file_name_extension(FileName,BaseName,_)
. Useful to extract the base name of a file using functional syntax.
extension(FileName, Extension)
Extension
is the extension (suffix) of FileName
. Equivalent to file_name_extension(FileName,_,Extension)
. Useful to extract the extension of a file using functional syntax.
Go to the first, previous, next, last section, table of contents.