summaryrefslogtreecommitdiff
path: root/dired-rmjunk.el
diff options
context:
space:
mode:
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