file-author
file-author Function
Syntax:
file-author pathspec → author
Arguments and Values:
pathspec—a pathname designator .
author—a string or nil.
Description:
Returns a string naming the author of the file specified by pathspec, or nil if the author’s name cannot be determined.
Examples:
(with-open-file (stream ">relativity>general.text")
(file-author s))
→ "albert"
Affected By:
The host computer’s file system.
Other users of the file named by pathspec.
Exceptional Situations:
An error of type file-error is signaled if pathspec is wild.
An error of type file-error is signaled if the file system cannot perform the requested operation.
See Also:
pathname, logical-pathname, Section 20.1 (File System Concepts), Section 19.1.2 (Pathnames as Filenames)
Expanded Reference: file-author
Querying the author of a file
file-author returns a string naming the author of the specified file, or nil if the author cannot be determined. Support for file authorship is implementation-dependent and file-system-dependent.
;; On many Unix systems, file-author returns the owner's login name
(with-open-file (s "/tmp/cl-author-test.txt" :direction :output
:if-exists :supersede)
(write-string "test" s))
(file-author "/tmp/cl-author-test.txt")
;; => "username" ; implementation-dependent
Result type is string or nil
The return value is always either a string or nil. Many modern file systems do not track authorship separately from ownership.
(let ((author (file-author "/tmp/cl-author-test.txt")))
(or (stringp author) (null author)))
=> T
Accepts pathname designators
Like most file functions, file-author accepts strings, pathnames, and streams as its argument.
(file-author #P"/tmp/cl-author-test.txt")
;; => "username" ; implementation-dependent
(with-open-file (s "/tmp/cl-author-test.txt")
(file-author s))
;; => "username" ; implementation-dependent