From 0ef0ccaa908a1c2baa04905727ec12a5caef4a25 Mon Sep 17 00:00:00 2001 From: "Jakob L. Kreuze" Date: Sat, 25 May 2019 14:22:50 -0400 Subject: Implement #'--dir-name and #'--file-name --- dired-rmjunk.el | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'dired-rmjunk.el') 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 ;; 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 -- cgit v1.3