Improve loading of files

This commit is contained in:
Tom Willemsen 2012-09-26 19:52:02 +02:00
parent 40566cee5b
commit 9c683792be

View file

@ -80,18 +80,11 @@
(define (stored-file xdg-env file)
"Try to get FILE stored either in XDG-ENV or the home directory."
(let ((xdg (getenv xdg-env))
(home (getenv "HOME"))
(result #f))
(cond
(xdg
(let ((xdg-stored-file (string-append xdg "/undone/" file)))
(when (file-exists? xdg-stored-file)
(set! result xdg-stored-file))))
(home
(let ((home-stored-file (string-append home "/.undone/" file)))
(when (file-exists? home-stored-file)
(set! result home-stored-file)))))
result))
(stored-file (string-append
(getenv "HOME") "/.undone/" file)))
(unless (or (file-exists? stored-file) (not xdg))
(set! stored-file (string-append xdg "/undone/" file)))
stored-file))
(define (config-file file)
"Try to get FILE from the configuration file location."