This is the ppath Reference Manual, version 0.1, generated automatically by Declt version 4.0 beta 2 "William Riker" on Sun Dec 15 07:20:04 2024 GMT+0.
The main system appears first, followed by any subsystem dependency.
ppath
A Common Lisp path handling library based on Python’s os.path module
Alexey Veretennikov
BSD
[![Build Status](https://travis-ci.org/fourier/ppath.svg?branch=master)](https://travis-ci.org/fourier/ppath)
# A Common Lisp path strings manipulation library.
This library is a path strings manipulation library inspired by Python’s **os.path**. All functionality from **os.path** is supported on major operation systems (OSX, Linux, Windows).
The philosophy behind is to use simple strings and "dumb" string manipulation functions to handle paths and filenames. Where possible the corresponding OS system functions are called.
Supported [tested] compilers: LispWorks (6.1PE and 7.0), CCL, SBCL.
Tested on the following platforms:
#### Windows
- Clozure CL Version 1.11-r16635 (WindowsX8664)
- LispWorks 6.1.1 Personal Edition 32bit
- LispWorks 7.0 Hobbyist Edition 32bit
- SBCL 1.3.15
Limitations: On Win32 assumed OS versions with Unicode support.
#### Linux
- SBCL 1.3.14
- CCL 1.11.5
#### OSX
- Lispworks 7.0 Hobbyist DV Edition 32bit
- Clozure CL Version 1.11
## Usage
The library consist of 3 packages: *ppath*, *ppath-nt* and *ppath-posix*. The generic package *ppath* forwards calls to appropriate OS-dependent library. It exports only functions available for the current platform.
## Semantical difference from Python’s os.path module
- Where possible do not raise an error, but rather return “‘nil“‘.
- “‘samestat“‘ function is not implemented (makes no sense since osicat’s wrapper around stat()/fstat() calls is used)
- “‘walk“‘ is not implemented (there is already a couple of good implementations around)
## API description
### *constant* ppath:+separator+
The os path separation character (as a character).
If os is posix: ‘#\/‘
If os is windows: ‘#\\‘
Example:
On Windows:
“‘lisp
CL-USER > ppath:+separator+
=> #\\
“‘
On POSIX:
“‘lisp
CL-USER > ppath:+separator+
=> #\/
“‘
### *constant* ppath:+sep-string+
Converts the value of ‘ppath:+separator+‘ to a string.
If os is posix: ‘"/"‘
If os is windows: ‘"\\"‘
Example:
On Windows:
“‘lisp
CL-USER > ppath:+sep-string+
=> "\\"
“‘
On POSIX:
“‘lisp
CL-USER > ppath:+sep-string+
=> "/"
“‘
### *constant* ppath:+posix-separator+
The explicit posix separation character: ‘#\/‘
Example:
“‘lisp
CL-USER > ppath:+posix-separator+
=> #\/
“‘
### *constant* ppath:+unc-prefix+
The explicit unc-prefix string: ‘"//"‘
Example:
“‘lisp
CL-USER > ppath:+unc-prefix+
=> "//"
“‘
### *constant* ppath:+path-separator+
The explicit $PATH separation character.
If os is posix: ‘#\:‘
If os is windows: ‘#\;‘
Example:
On Windows:
“‘lisp
CL-USER > ppath:+path-separator+
=> #\;
“‘
On POSIX:
“‘lisp
CL-USER > ppath:+path-separator+
=> #\:
“‘
### *constant* ppath:+current-dir+
The relative current directory as a string: ‘"."‘
Example:
“‘lisp
CL-USER > ppath:+current-dir+
=> "."
“‘
### *constant* ppath:+up-dir+
The relative parent directory as a string: ‘".."‘
Example:
“‘lisp
CL-USER > ppath:+up-dir+
=> ".."
“‘
### *constant* ppath:+secs-between-epochs+
A constant value: ‘11644473600‘
Example:
“‘lisp
CL-USER > ppath:+secs-between-epochs+
=> 11644473600
“‘
### *function* ppath:abspath (“‘path“‘)
Convert relative “‘path“‘ to absolute.
If path is absolute return it unchanged.
If path is empty return current directory.
On POSIX systems invariant:
“‘(abspath path) == (normpath (join (getcwd) path))“‘
### *function* ppath:basename (“‘path“‘)
Extract the base name (filename) of the “‘path“‘.
Example:
On Windows:
“‘lisp
CL-USER > (basename "C:\\dir\\file.txt")
=> file.txt
“‘
On POSIX:
“‘lisp
CL-USER > (basename "/foo/bar")
=> bar
“‘
Invariant:
“‘(basename path) == (cdr (split path))“‘
### *function* ppath:commonprefix (“‘&rest paths“‘)
Get the common prefix substring of all strings in “‘paths“‘. The separators are not translated, so paths interpreted just as normal strings.
“‘paths“‘ components could also be lists of strings, like results of “‘split“‘ operation on paths. In this case the comparison happens elementwise.
Example:
“‘lisp
CL-USER > (commonprefix ’("/home/username/dir" "/home/user/test"))
=> /home/user
“‘
### *function* ppath:dirname (“‘path“‘)
Get the directory name of the “‘path“‘.
Example:
“‘lisp
CL-USER > (dirname "/foo/bar")
=> /foo
“‘
Example (Windows):
“‘lisp
CL-USER > (dirname "C:\\dir\\file.txt")
=> C:\\dir
“‘
Invariant: “‘(dirname path) == (car (split path))“‘
### *function* ppath:exists (“‘path“‘)
Check if the “‘path“‘ is an existing path.
On POSIX returns “‘nil“‘ for broken symbolic links.
### *function* ppath:expanduser (“‘PATH“‘)
Expand ~ and ~user in the “‘path“‘ with the contents of user’s home path.
* ~ - home directory
* ~user - user’s home directory
Return “‘path“‘ unchanged if unable to expand.
On Windows the path is taken either from **HOME** or **USERPROFILE**, or constructed via **HOMEPATH** and **HOMEDRIVE**.
On error just return original “‘path“‘ value.
On POSIX systems the ~ is replaced with contents of the **HOME** environment variable or taken from password database (“‘/etc/passwd“‘ or similar).
Examples (POSIX): (given the user "username" with home directory /Users/username)
“‘lisp
CL-USER > (expanduser "~/dir")
=> /Users/username/dir
CL-USER > (expanduser "~root/dir")
=> /root/dir
“‘
Windows: if **HOMEPATH** is "users\dir" and **HOMEDRIVE** is "C:\\",
“‘lisp
CL-USER > (expanduser "~test")
=> C:\users\test
“‘
### *function* ppath:expandvars (“‘path &optional (modify-in-quotes t)“‘)
Expand the “‘path“‘ replacing environment variables with their contents.
The variables like “‘${var}“‘ and “‘$var“‘ (and additionally “‘%var%“‘ on Windows) are getting replaced by their values.
All unknown or malformed variables ignored and kept as it is.
The difference between Windows and POSIX systems is that on Windows variables inside single quotes are not expanded, i.e. "“‘’$HOME’“‘" will remain "“‘’$HOME’“‘", while on POSIX systems it will be expanded. The optional argument “‘modify-in-quotes“‘ allows to change this behavior.
This behavior kept for compatibility with Python’s “‘os.path.expandvars“‘.
Example:
“‘lisp
CL-USER > (expandvars "$HOME/.bashrc")
=> /home/username/.bashrc
CL-USER > (osicat-posix:setenv "foo" "abcd")
=> 0
CL-USER > (expandvars "’$foo’$bar" nil)
=> ’$foo’$bar
CL-USER > (expandvars "’$foo’$bar" t)
=> ’abcd’$bar
“‘
### *function* ppath:getatime (“‘path“‘)
Return the last access time for the “‘path“‘.
Return value is seconds since Unix Epoch (1970-01-01T00:00:00Z).
Return “‘nil“‘ if unable to access file or get its attributes.
### *function* ppath:getctime (“‘path“‘)
Return the last status change time for the “‘path“‘.
Return value is seconds since Unix Epoch (1970-01-01T00:00:00Z).
Return “‘nil“‘ if unable to access file or get its attributes.
### *function* ppath:getmtime (“‘path“‘)
Return the last modification time for the “‘path“‘.
Return value is seconds since Unix Epoch (1970-01-01T00:00:00Z).
Return “‘nil“‘ if unable to access file or get its attributes.
### *function* ppath:getsize (“‘path“‘)
Get the file size in bytes of the “‘path“‘.
Return “‘nil“‘ if unable to access file or get its attributes.
### *function* ppath:isabs (“‘path“‘)
Determine if the “‘path“‘ is an absolute pathname.
This function never checks for file existance nor address
file system but rather performs string manipulations to
determine if the “‘path“‘ is an absolute filename.
Examples (POSIX):
“‘lisp
CL-USER > (isabs "/Sources/lisp")
=> t
CL-USER > (isabs "my/dir")
=> nil
“‘
Examples (Windows):
“‘lisp
CL-USER > (isabs "\\\\host-name\\share-name\\")
=> t
“‘
### *function* ppath:isdir (“‘path“‘)
Determine if “‘path“‘ is an existing directory. If the “‘path“‘ is symlink then the invariant
“‘(and (islink path) (isdir path)) == t“‘
holds.
### *function* ppath:isfile (“‘path“‘)
Determine if the “‘path“‘ exists and a file. Returns also “‘t“‘ for symbolic links.
### *function* ppath:islink (“‘path“‘)
Determine if the “‘path“‘ is symbolic link.
On Windows always return “‘nil“‘.
### *function* ppath:ismount (“‘path“‘)
Test if the “‘path“‘ is a mount point.
On POSIX it is a directory where another filesystem is mounted.
On Windows for local paths it should be an absolute path, for UNC it should be mount point of the host
Example:
“‘lisp
CL-USER > (ismount "/mnt")
=> nil
CL-USER > (ismount "/mnt/cdrom")
=> t
“‘
### *function* ppath:join (“‘path &rest paths“‘)
Join paths provided, merging (if absolute) and
inserting missing separators.
Example:
“‘lips
CL-USER > (join "a/b" "x/y")
=> a/b\\x/y
CL-USER > (join "c:\\hello" "world/test.txt")
=> c:\\hello\\world/test.txt
CL-USER > (join "/foo" "bar" "baz")
=> /foo/bar/baz
CL-USER > (join "/foo/" "bar/" "baz/")
=> /foo/bar/baz/
“‘
### *function* ppath:lexists (“‘path“‘)
Check if the “‘path“‘ is an existing path.
Checks for existance regardless if “‘path“‘ is a link(even broken) or a file/directory.
On Windows “‘exists“‘ = “‘lexists“‘.
### *function* ppath:normcase (“‘path“‘)
Normalize the “‘path“‘.
On Windows, replace slash with backslahes and lowers the case of the “‘path“‘.
On POSIX do nothing and just return “‘path“‘.
### *function* ppath:normpath (“‘path“‘)
Normalize path, removing unnecessary/redundant parts, like dots, double slashes, etc. Expanding “‘..“‘ as well.
Example:
“‘lisp
CL-USER > (normpath "///..//./foo/.//bar")
=> /foo/bar
“‘
### *function* ppath:realpath (“‘path“‘)
Return real “‘path“‘ of the file, following symlinks if necessary. On Windows just return (abspath path). The “‘path“‘ shall be already expanded properly.
Return “‘nil“‘ if “‘path“‘ does not exist or not accessible
### *function* ppath:relpath (“‘path &optional (start ".")“‘)
Return the relative version of the “‘path“‘.
If “‘startdir“‘ provided, use this as a current directory to resolve against.
### *function* ppath:samefile (“‘path1 path2“‘)
Determine if “‘path1“‘ and “‘path2“‘ are the paths to the same file.
If one of the paths is symlink to another they considered the same.
*Not available on Windows.*
### *function* ppath:sameopenfile (“‘stream1 stream2“‘)
Determine if the open file streams “‘stream1“‘ and “‘stream2“‘ are of the same file.
*Not available on Windows.*
### *function* ppath:split (“‘path“‘)
Split the path into the pair “‘(directory . filename)“‘.
If the path ends with "/", the file component is empty.
On Windows, if the head is a drive name, the slashes are not stripped from it.
Examples:
(On Windows)
“‘lisp
CL-USER > (split "c:\\Sources\\lisp")
=> ("c:\\Sources" . "lisp")
CL-USER > (split "\\\\host-name\\share-name\\dir1\\dir2")
=> ("\\\\host-name\\share-name\\dir1" . "dir2")
“‘
(on POSIX)
“‘lisp
CL-USER > (split "/foo/bar")
=> ("/foo" . "bar")
CL-USER > (split "/foo/bar/")
=> ("/foo/bar/" . "")
“‘
### *function* ppath:splitdrive (“‘path“‘)
Split a “‘path“‘ to the drive (with letter) and path after the drive.
This function also parses the UNC paths, providing \\hostname\mountpoint as a drive part.
On POSIX drive is an empty string.
Invariant: “‘(concatenate ’string (car (splitdrive path)) (cdr (splitdrive path))) == path“‘
Example:
“‘lisp
CL-USER > (splitdrive "C:\Sources\lisp")
=> ("C:" "\Sources\lisp")
“‘
### *function* ppath:splitext (“‘path“‘)
Split “‘path“‘ to root and extension. Return a pair “‘(root . ext)“‘
If the filename component of the “‘path“‘ starts with dot, like “‘.cshrc“‘, considering no extension.
Invariant: “‘(concatenate ’string root ext) == path“‘
Examples:
“‘lisp
CL-USER > (splitext "~/test.cshrc")
=> ("~/test" . ".cshrc")
CL-USER > (splitext "~/notes.txt")
=> ("~/notes" . ".txt")
“‘
### *function* ppath:splitparts (“‘path“‘)
Split the “‘path“‘ to the list of elements using. Separators are not omitted.
Example:
“‘lisp
CL-USER > (ppath:splitparts "/abc/def/gh//12")
=> ("/" "abc" "/" "def" "/" "gh" "//" "12")
“‘
### *function* ppath:splitunc (“‘path“‘)
Split a pathname with UNC path. UNC syntax: “‘\\host-name\share-name\file_path“‘
Return a cons pair “‘("\\host-name\share-name" . "\file_path")“‘
*Not available on POSIX.*
## Author
* Alexey Veretennikov (alexey.veretennikov@gmail.com)
## Copyrights
- Python and Python documentation Copyright (c) 1990-2018, Python Software Foundation.
- Parts of Python documentation on https://docs.python.org/2.7/library/os.path.html were used and adapted when necessary to the current implementation.
## License
Licensed under the BSD License.
0.1
alexandria
(system).
cffi
(system).
osicat
(system).
uiop
(system).
trivial-features
(system).
cl-ppcre
(system).
split-sequence
(system).
src
(module).
Modules are listed depth-first from the system components tree.
ppath/src
ppath
(system).
details
(module).
ppath.lisp
(file).
ppath/src/details
src
(module).
constants.lisp
(file).
posix-cffi.lisp
(file).
generic.lisp
(file).
posix.lisp
(file).
Files are sorted by type and then listed depth-first from the systems components trees.
ppath/ppath.asd
ppath/src/details/constants.lisp
ppath/src/details/posix-cffi.lisp
ppath/src/details/generic.lisp
ppath/src/details/posix.lisp
ppath/src/ppath.lisp
ppath/src/details/constants.lisp
details
(module).
+current-dir+
(constant).
+path-separator+
(constant).
+posix-separator+
(constant).
+secs-between-epochs+
(constant).
+sep-string+
(constant).
+separator+
(constant).
+unc-prefix+
(constant).
+up-dir+
(constant).
ppath/src/details/posix-cffi.lisp
constants.lisp
(file).
details
(module).
getpid
(function).
+path-max+
(constant).
array-to-hex
(function).
foreign-ptr-to-string
(function).
ppath/src/details/generic.lisp
posix-cffi.lisp
(file).
details
(module).
commonprefix
(function).
concat
(function).
get-temp-path
(function).
getcwd
(function).
getenv
(function).
getpid
(function).
path-error
(condition).
split-components
(function).
splitext
(function).
string-type
(type).
path-error-function
(reader method).
reason
(reader method).
sep-p
(function).
wildcard-to-regex
(function).
ppath/src/details/posix.lisp
generic.lisp
(file).
details
(module).
abspath
(function).
basename
(function).
dirname
(function).
exists
(function).
expanduser
(function).
expandvars
(function).
getatime
(function).
getctime
(function).
getmtime
(function).
getsize
(function).
isabs
(function).
isdir
(function).
isfile
(function).
islink
(function).
ismount
(function).
join
(function).
lexists
(function).
normcase
(function).
normpath
(function).
realpath
(function).
relpath
(function).
samefile
(function).
sameopenfile
(function).
split
(function).
equal-osicat-ts
(function).
fd-from-stream
(function).
getpwnam
(function).
getpwuid
(function).
getuid
(function).
listdir
(function).
or-strings
(function).
osicat-check-no-file
(macro).
samestat
(function).
ppath/src/ppath.lisp
details
(module).
src
(module).
+current-dir+
(constant).
+path-separator+
(constant).
+posix-separator+
(constant).
+secs-between-epochs+
(constant).
+sep-string+
(constant).
+separator+
(constant).
+unc-prefix+
(constant).
+up-dir+
(constant).
abspath
(function).
basename
(function).
commonprefix
(function).
dirname
(function).
exists
(function).
expanduser
(function).
expandvars
(function).
getatime
(function).
getctime
(function).
getmtime
(function).
getsize
(function).
isabs
(function).
isdir
(function).
isfile
(function).
islink
(function).
ismount
(function).
join
(function).
lexists
(function).
normcase
(function).
normpath
(function).
realpath
(function).
relpath
(function).
samefile
(function).
sameopenfile
(function).
split
(function).
splitdrive
(function).
splitext
(function).
splitparts
(function).
splitunc
(function).
Packages are listed by definition order.
ppath.details.generic
ppath-asd
ppath.details.constants
ppath.details.posix.cffi
ppath.details.posix
ppath
ppath.details.generic
alexandria
.
common-lisp
.
ppath.details.constants
.
commonprefix
(function).
concat
(function).
get-temp-path
(function).
getcwd
(function).
getenv
(function).
getpid
(function).
path-error
(condition).
split-components
(function).
splitext
(function).
string-type
(type).
path-error-function
(generic reader).
reason
(generic reader).
sep-p
(function).
wildcard-to-regex
(function).
ppath.details.constants
alexandria
.
common-lisp
.
+current-dir+
(constant).
+path-separator+
(constant).
+posix-separator+
(constant).
+secs-between-epochs+
(constant).
+sep-string+
(constant).
+separator+
(constant).
+unc-prefix+
(constant).
+up-dir+
(constant).
ppath.details.posix.cffi
alexandria
.
cffi
.
common-lisp
.
getpid
(function).
+path-max+
(constant).
array-to-hex
(function).
foreign-ptr-to-string
(function).
ppath.details.posix
ppath-posix
alexandria
.
common-lisp
.
ppath.details.constants
.
abspath
(function).
basename
(function).
dirname
(function).
exists
(function).
expanduser
(function).
expandvars
(function).
getatime
(function).
getctime
(function).
getmtime
(function).
getsize
(function).
isabs
(function).
isdir
(function).
isfile
(function).
islink
(function).
ismount
(function).
join
(function).
lexists
(function).
normcase
(function).
normpath
(function).
realpath
(function).
relpath
(function).
samefile
(function).
sameopenfile
(function).
split
(function).
equal-osicat-ts
(function).
fd-from-stream
(function).
getpwnam
(function).
getpwuid
(function).
getuid
(function).
listdir
(function).
or-strings
(function).
osicat-check-no-file
(macro).
samestat
(function).
ppath
alexandria
.
common-lisp
.
+current-dir+
(constant).
+path-separator+
(constant).
+posix-separator+
(constant).
+secs-between-epochs+
(constant).
+sep-string+
(constant).
+separator+
(constant).
+unc-prefix+
(constant).
+up-dir+
(constant).
abspath
(function).
basename
(function).
commonprefix
(function).
dirname
(function).
exists
(function).
expanduser
(function).
expandvars
(function).
getatime
(function).
getctime
(function).
getmtime
(function).
getsize
(function).
isabs
(function).
isdir
(function).
isfile
(function).
islink
(function).
ismount
(function).
join
(function).
lexists
(function).
normcase
(function).
normpath
(function).
realpath
(function).
relpath
(function).
samefile
(function).
sameopenfile
(function).
split
(function).
splitdrive
(function).
splitext
(function).
splitparts
(function).
splitunc
(function).
Definitions are sorted by export status, category, package, and then by lexicographic order.
Seconds between 1.1.1601 and 1.1.1970
Return an absolute path.
Convert relative PATH to absolute. If path is absolute return it unchanged,
if path is empty return current directory
On POSIX systems invariant:
(abspath path) == (normpath (join (getcwd) path))
holds
Returns filename component of the PATH
Extract the base name (filename) of the PATH.
Example:
On Windows:
CL-USER > (basename "C:\\dir\\file.txt")
=> file.txt
On POSIX:
CL-USER > (basename "/foo/bar")
=> bar
Invariant: (basename path) == (cdr (split path))
Get the common prefix substring of all strings in PATHS.
PATHS components could also be lists of strings, like results of
SPLIT operation on paths.
If no common prefix return empty string.
Get the common prefix substring of all strings in PATHS. The separators are not translated,
so paths interpreted just as normal strings.
PATHS components could also be lists of strings, like results of
SPLIT operation on paths. In this case the comparison happens elementwise.
Example:
CL-USER > (commonprefix ’("/home/username/dir" "/home/user/test"))
=> /home/user
Concatenate strings in a portable manner, converting to unicode string if necessary
Returns directory component of the PATH
Get the directory name of the PATH.
Example:
CL-USER > (dirname "/foo/bar")
=> /foo
Example (Windows):
CL-USER > (dirname "C:\\dir\\file.txt")
=> C:\\dir
Invariant: (dirname path) == (car (split path))
Return true if path exists. If file is a broken link return nil
Check if the PATH is an existing path.
On POSIX returns nil for broken symbolic links.
Expand ~ and ~user inside the PATH.
If the PATH not starts with ~ it return unchanged.
Return PATH unchanged if unable to expand
Expand ~ and ~user in the PATH with the contents of user’s home path.
~ - home directory
~user - user’s home directory
Return PATH unchanged if unable to expand.
On Windows the path is taken either from HOME or USERPROFILE, or constructed via HOMEPATH and HOMEDRIVE.
On error just return original PATH value.
On POSIX systems the ~ is replaced with contents of the HOME environment variable or taken from password database
(/etc/passwd or similar).
Examples (POSIX): (given the user "username" with home directory /Users/username)
CL-USER > (expanduser "~/dir")
=> /Users/username/dir
CL-USER > (expanduser "~root/dir")
=> /root/dir
Windows: if HOMEPATH is "users\dir" and HOMEDRIVE is "C:\\",
CL-USER > (expanduser "~test")
=> C:\users\test
Expand environment variables in PATH of form $VAR and ${VAR}, if variables exist. Otherwise they stay unchanged in the output. Optional argument MODIFY-IN-QUOTES if set to t (default) perform replacement inside single quotes. Otherwise strings like ’$HOME’ will left as it is.
Expand the PATH replacing environment variables with their contents.
The variables like ${var} and $var (and additionally %var% on Windows) are getting replaced by their values.
All unknown or malformed variables ignored and kept as it is.
The difference between Windows and Posix systems is that on Windows variables inside single quotes are not
expanded, i.e. "’$HOME’" will remain "’$HOME’", while on Posix systems it will be expanded. The optional argument MODIFY-IN-QUOTES allows to change this behavior.
This behavior kept for compatibility with Python’s os.path.expandvars.
Example:
CL-USER > (expandvars "$HOME/.bashrc")
=> /home/fourier/.bashrc
CL-USER > (osicat-posix:setenv "foo" "abcd")
=> 0
CL-USER > (expandvars "’$foo’$bar" nil)
=> ’$foo’$bar
CL-USER > (expandvars "’$foo’$bar" t)
=> ’abcd’$bar
Return the path to the temporary files directory
Return the last access time for the PATH.
Return value is seconds since Unix Epoch (1970-01-01T00:00:00Z).
Return the last access time for the PATH.
Return value is seconds since Unix Epoch (1970-01-01T00:00:00Z).
Return nil if unable to access file or get its attributes.
Return the last status change time for the PATH.
Return value is seconds since Unix Epoch (1970-01-01T00:00:00Z).
Return the last status change time for the PATH.
Return value is seconds since Unix Epoch (1970-01-01T00:00:00Z).
Return nil if unable to access file or get its attributes.
Get the current working directory as a string
Get system environment variable value.
Return the last modification time for the PATH.
Return value is seconds since Unix Epoch (1970-01-01T00:00:00Z).
Return the last modification time for the PATH.
Return value is seconds since Unix Epoch (1970-01-01T00:00:00Z).
Return nil if unable to access file or get its attributes.
Return the current process id
Return the file size
Get the file size in bytes of the PATH.
Return nil if unable to access file or get its attributes.
Return t if the path is absolute.
Determine if the PATH is an absolute pathname.
This function never checks for file existance nor address
file system but rather performs string manipulations to
determine if the PATH is an absolute filename.
Examples (POSIX):
CL-USER > (isabs "/Sources/lisp")
=> t
CL-USER > (isabs "my/dir")
=> nil
Examples (Windows):
CL-USER > isabs "\\\\host-name\\share-name\\")
=> t
Determine if the PATH is a directory
Determine if PATH is an existing directory. If the PATH is symlink then the invariant (and (islink PATH) (isdir PATH)) holds.
Determine if the PATH is a regular file
Determine if the PATH exists and a file. Returns also t for symbolic links.
Determine if the PATH is a symbolic link
Determine if the PATH is symbolic link. On Windows always return nil.
Determine if the PATH is a mount point
Test if the path is a mount point.
On POSIX it is a directory where another filesystem is mounted.
On Windows for local paths it should be
an absolute path, for UNC it should be mount point of the host
Example:
CL-USER > (ismount "/mnt")
=> nil
CL-USER > (ismount "/mnt/cdrom")
=> t
Join paths provided, merging (if absolute) and
inserting missing separators.
Example:
CL-USER > (join "a/b" "x/y")
=> a/b\\x/y
CL-USER > (join "c:\\hello" "world/test.txt")
=> c:\\hello\\world/test.txt
CL-USER > (join "/foo" "bar" "baz")
=> /foo/bar/baz
CL-USER > (join "/foo/" "bar/" "baz/")
=> /foo/bar/baz/
Return true if path exists, regardless if its a link(even broken) or a file/directory
Check if the PATH is an existing path.
Checks for existance regardless if PATH is a link(even broken) or a file/directory.
On Windows exists=lexists.
Normalize case of PATH.
On case-sensitive file systems (default on Linux and OSX) just returns PATH unchanged
Normalize the PATH.
On Windows, replace slash with backslahes and lowers the case of the PATH.
On POSIX do nothing and just return PATH.
Normalize path, removing unnecessary/redundant parts, like dots,
double slashes, etc. Expanding .. as well.
Example:
///..//./foo/.//bar => /foo/bar
Normalize path, removing unnecessary/redundant parts, like dots,
double slashes, etc. Expanding .. as well.
Example:
CL-USER > (normpath "///..//./foo/.//bar")
=> /foo/bar
Return real path of the file, following symlinks if necessary
Return real PATH of the file, following symlinks if necessary.
On Windows just return (abspath path).
The PATH shall be already expanded properly.
Return nil if PATH does not exist or not accessible
Convert PATH from absolute to relative
Return the relative version of the PATH.
If STARTDIR specified, use this as a current directory to resolve against.
Determine if PATH1 and PATH2 are the paths to the same file.
If one of the paths is symlink to another they considered the same.
Determine if PATH1 and PATH2 are the paths to the same file.
If one of the paths is symlink to another they considered the same.
Not available on Windows.
Determine if the open file streams STREAM1 and STREAM2 are of the same file
Determine if the open file streams STREAM1 and STREAM2 are
of the same file.
Not available on Windows.
Split the path into the pair (directory . filename). If the path ends with "/", the file component is empty
Split the path into the pair (directory . filename).
If the path ends with "/", the file component is empty
On Windows, if the head is a drive name, the slashes are not stripped from it.
Examples:
(On Windows)
CL-USER > (split "c:\\Sources\\lisp")
=> ("c:\\Sources" . "lisp")
CL-USER > (split "\\\\host-name\\share-name\\dir1\\dir2")
=> ("\\\\host-name\\share-name\\dir1" . "dir2")
(on POSIX)
CL-USER > (split "/foo/bar")
=> ("/foo" . "bar")
CL-USER > (split "/foo/bar/")
=> ("/foo/bar/" . "")
Splits the path to the list of elements using
slash as a separator. Separators are not omitted.
Example:
(split-components "/abc/def/gh//12")
=> ("/" "abc" "/" "def" "/" "gh" "//" "12")
Split a path to the drive (with letter) and path after drive.
This function also parses the UNC paths, providing \\hostname\mountpoint
as a drive part.
On POSIX drive is an empty string.
Invariant: (concatenate ’string (car (splitdrive path)) (cdr (splitdrive path))) == path
Example:
CL-USER > (splitdrive "C:\Sources\lisp")
=> ("C:" "\Sources\lisp")
Split path to path and extension. Extension is the text
after the last dot.
Invariant: (concatenate ’string root ext) == p)
Split PATH to root and extension. Return a pair (root . ext)
If the filename component of the PATH starts with dot, like .cshrc, considering no extension.
Invariant: (concatenate ’string root ext) == path
Examples:
CL-USER > (splitext "~/test.cshrc")
=> ("~/test" . ".cshrc")
CL-USER > (splitext "~/notes.txt")
=> ("~/notes" . ".txt")
Splits the path to the list of elements using. Separators are not omitted.
Example:
CL-USER > (splitparts "/abc/def/gh//12")
=> ("/" "abc" "/" "def" "/" "gh" "//" "12")
Test if osicat timespecs are equal
Get the posix file handle from open STREAM
Get the list of values from DirectoryService (and /etc/passwd) by user name.
Returns the list:
username
password(will have only * most likely)
user id
group id
full user name
user home directory
user shell
Get the list of values from DirectoryService (and /etc/passwd) by user id.
Returns the list:
username
password(will have only * most likely)
user id
group id
full user name
user home directory
user shell
Get the current user id
Return the list of all files/directories in the PATH specified.
Special names like . and .. are omitted.
No specific order assumed.
Assuming PATH is an absolute path to the directory
Return nil if not able to access
Auxulary helper function, return the first not empty string from its arguments
Tests if 2 osicat-posix:stat structs are the same
Split a pathname with UNC path. UNC syntax:
\\host-name\share-name\file_path
Return a cons pair (\\host-name\share-name . \file_path)
Not available on POSIX.
Convert file wildcards to regular expressions. By default the regular
expression is case sensitive. This is regulated by keyword argument
CASE-SENSITIVE-P.
Parameters BEGINNING-OF-STRING and END-OF-STRING identify whether the beginning of the string (^)
or end of string ($) marker should be present.
Supported patters:
* - everything
? - any character
[range] - any character in range
[!range] - any character not in range
Note that directory separator characters ’/’ and ’\’
are treated the same way as other characters, so
the function is used to treat complex paths they
better to be splitted.
Example:
=> (wildcard-to-regex "Photo*.jpg")
"^Photo.*\\.jpg$"
=> (wildcard-to-regex "Photo*.jpg" :case-sensitive-p nil)
"(?i)^Photo.*\\.jpg$"
path-error
)) ¶path-error
)) ¶Jump to: | A B C D E F G I J L M N O P R S W |
---|
Jump to: | A B C D E F G I J L M N O P R S W |
---|
Jump to: | +
C F R S |
---|
Jump to: | +
C F R S |
---|
Jump to: | C D F G M P S T |
---|
Jump to: | C D F G M P S T |
---|