summaryrefslogtreecommitdiff
path: root/dired-rmjunk.el
diff options
context:
space:
mode:
authorJakob L. Kreuze <zerodaysfordays@sdf.lonestar.org>2019-05-25 14:22:50 -0400
committerJakob L. Kreuze <zerodaysfordays@sdf.lonestar.org>2019-05-25 14:22:50 -0400
commit0ef0ccaa908a1c2baa04905727ec12a5caef4a25 (patch)
treeba4d80e6117ca243fc693b167ee8ec5d6931a176 /dired-rmjunk.el
parent730541414a5fb7c7dad64f54ba912809c63a028f (diff)
Implement #'--dir-name and #'--file-name
Diffstat (limited to 'dired-rmjunk.el')
-rw-r--r--dired-rmjunk.el17
1 files changed, 16 insertions, 1 deletions
diff --git a/dired-rmjunk.el b/dired-rmjunk.el
index 8cb6c51..876af98 100644
--- a/dired-rmjunk.el
+++ b/dired-rmjunk.el
@@ -4,7 +4,7 @@
;; Author: Jakob L. Kreuze <zerodaysfordays@sdf.lonestar.org>
;; Version: 1.0
-;; Package-Requires (dired)
+;; Package-Requires (cl-lib dired)
;; Keywords: files matching
;; URL: https://git.sr.ht/~jakob/dired-rmjunk
@@ -70,5 +70,20 @@ patterns in `dired-rmjunk-patterns'."
"No junk files found :)"
"Junk files marked."))))))
+(defun dired-rmjunk--dir-name (path)
+ "Return the directory portion of PATH, or `nil' if the path
+does not contain a directory component."
+ (let ((split-offset (cl-position ?\/ path :from-end t)))
+ (if split-offset
+ (cl-subseq path 0 (1+ split-offset)))))
+
+(defun dired-rmjunk--file-name (path)
+ "Return the file-name portion of PATH."
+ (let ((split-offset (cl-position ?\/ path :from-end t)))
+ (if split-offset
+ (cl-subseq path (1+ split-offset))
+ ;; If there's no directory component, `path' IS the file-name!
+ path)))
+
(provide 'dired-rmjunk)
;;; dired-rmjunk.el ends here