Reduce code complexity for fileops
This commit is contained in:
parent
b13b797315
commit
242da4e070
1 changed files with 10 additions and 17 deletions
|
@ -2,30 +2,23 @@
|
||||||
|
|
||||||
(defun base-dir ()
|
(defun base-dir ()
|
||||||
(let ((os (uiop:detect-os)))
|
(let ((os (uiop:detect-os)))
|
||||||
(cond ((eq os :os-windows)
|
(uiop:parse-native-namestring
|
||||||
(format nil "~a/" (uiop:getenv "LOCALAPPDATA")))
|
(cond ((eq os :os-windows)
|
||||||
|
(format nil "~a/" (uiop:getenv "LOCALAPPDATA")))
|
||||||
|
|
||||||
((eq os :os-unix)
|
((eq os :os-unix)
|
||||||
(format nil "~a" (uiop:merge-pathnames*
|
(format nil "~a/.local/share/" (user-homedir-pathname)))
|
||||||
".local/share/"
|
|
||||||
(format nil
|
|
||||||
"~a/"
|
|
||||||
(uiop:getenv "HOME")))))
|
|
||||||
|
|
||||||
((eq os :os-macos)
|
((eq os :os-macos)
|
||||||
(format nil "~a" (uiop:merge-pathnames*
|
(format nil "~a/Library/Application Support/" (user-homedir-pathname)))
|
||||||
"Library/Application Support/"
|
|
||||||
(format nil
|
|
||||||
"~a/"
|
|
||||||
(uiop:getenv "HOME")))))
|
|
||||||
|
|
||||||
(t (error "Unsupported OS")))))
|
(t (error "Unsupported OS"))))))
|
||||||
|
|
||||||
(defun app-dir ()
|
(defun app-dir ()
|
||||||
(uiop:merge-pathnames* "ml-survey/" (base-dir)))
|
(uiop:merge-pathnames* #P"ml-survey/" (base-dir)))
|
||||||
|
|
||||||
(defun data-dir ()
|
(defun data-dir ()
|
||||||
(uiop:merge-pathnames* "data/surveys/" (app-dir)))
|
(uiop:merge-pathnames* #P"data/surveys/" (app-dir)))
|
||||||
|
|
||||||
(defun ensure-data-dir ()
|
(defun ensure-data-dir ()
|
||||||
(let ((data-dir (data-dir)))
|
(let ((data-dir (data-dir)))
|
||||||
|
|
Loading…
Add table
Reference in a new issue