diff options
| author | ckonstanski <ckonstanski@pippiandcarlos.com> | 2018-02-06 21:42:54 -0700 |
|---|---|---|
| committer | ckonstanski <ckonstanski@pippiandcarlos.com> | 2018-02-06 21:42:54 -0700 |
| commit | 142166df54eda65925921799a4bb3e7f6cdaba48 (patch) | |
| tree | 5dc70e16bd6719079651925b5c5769211a3bf27e /file/file-utils.lisp | |
initial commit
Diffstat (limited to 'file/file-utils.lisp')
| -rw-r--r-- | file/file-utils.lisp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/file/file-utils.lisp b/file/file-utils.lisp new file mode 100644 index 0000000..604a20f --- /dev/null +++ b/file/file-utils.lisp @@ -0,0 +1,28 @@ +;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*- +(declaim (optimize (speed 0) (safety 3) (debug 3))) + +(in-package #:music-dispensary) + +;; ========================================================================== ;; + +(defun mkdir (path) + (uffi:run-shell-command (format nil "mkdir -p ~a" path))) + +(defun file-exists-p (file-path) + (equal (car (shell-wrapper (format nil "if test -f '~a'; then echo 0; else echo 1; fi" file-path))) "0")) + +(defun directory-p (absolute-path) + (if (car (shell-wrapper (format nil "file '~a' |grep 'directory'" absolute-path))) t nil)) + +(defun symlink-p (absolute-path) + (if (car (shell-wrapper (format nil "file '~a' |grep 'symbolic link'" absolute-path))) t nil)) + +(defun file-p (absolute-path) + (if (or (directory-p absolute-path) (symlink-p absolute-path)) nil t)) + +(defun find-files (working-dir base-dir pattern) + (shell-wrapper (format nil + "pushd ~a >/dev/null 2>&1 ; find ~a -iname '~a' ; popd >/dev/null 2>&1" + working-dir + base-dir + pattern))) |
