ambrevar: Move directory-listing to `file' as `list-directory'.
parent
31a4fffa30
commit
a46c695a83
|
@ -105,6 +105,23 @@ This returns the directory name for directories."
|
||||||
:access-date (local-time:unix-to-timestamp (osicat-posix:stat-atime stat))
|
:access-date (local-time:unix-to-timestamp (osicat-posix:stat-atime stat))
|
||||||
:permissions (stat-permissions stat)))))))
|
:permissions (stat-permissions stat)))))))
|
||||||
|
|
||||||
|
(export-always 'list-directory)
|
||||||
|
(defun list-directory (&optional (path *default-pathname-defaults*) sort)
|
||||||
|
"Return entries in PATH.
|
||||||
|
By default, directories come first.
|
||||||
|
If SORT is non nil, sort them alphabetically.
|
||||||
|
Second value is the list of directories, third value is the non-directories."
|
||||||
|
;; TODO: Use locale to sort?
|
||||||
|
(let* ((subdirs (mapcar #'file (uiop:subdirectories path)))
|
||||||
|
(subfiles (mapcar #'file (uiop:directory-files path)))
|
||||||
|
(result (append subdirs subfiles)))
|
||||||
|
(values
|
||||||
|
(if sort
|
||||||
|
(sort result #'string< :key #'path)
|
||||||
|
result)
|
||||||
|
subdirs
|
||||||
|
subfiles)))
|
||||||
|
|
||||||
(export-always '*finder-include-directories*)
|
(export-always '*finder-include-directories*)
|
||||||
(defvar *finder-include-directories* t
|
(defvar *finder-include-directories* t
|
||||||
"When non-nil `walk' include directories.")
|
"When non-nil `walk' include directories.")
|
||||||
|
|
|
@ -108,18 +108,6 @@ Useful for `walk'."
|
||||||
(lambda (file)
|
(lambda (file)
|
||||||
(ppcre:scan "application/x-sharedlib" (first (file-mime-type file)))))
|
(ppcre:scan "application/x-sharedlib" (first (file-mime-type file)))))
|
||||||
|
|
||||||
(export-always 'directory-listing) ; TODO: Rename list-directory?
|
|
||||||
(defun directory-listing (path &key sort?)
|
|
||||||
"Return entries in PATH.
|
|
||||||
If SORT?, sort them alphabetically."
|
|
||||||
;; TODO: Use locale to sort?
|
|
||||||
(let ((result
|
|
||||||
(append (uiop:subdirectories path)
|
|
||||||
(uiop:directory-files path))))
|
|
||||||
(if sort?
|
|
||||||
(sort result #'string< :key #'namestring)
|
|
||||||
result)))
|
|
||||||
|
|
||||||
(export-always 'delete-empty-directory-upward)
|
(export-always 'delete-empty-directory-upward)
|
||||||
(defun delete-empty-directory-upward (directory)
|
(defun delete-empty-directory-upward (directory)
|
||||||
"Delete directory and its parents until non-empty.
|
"Delete directory and its parents until non-empty.
|
||||||
|
|
Loading…
Reference in New Issue