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) (define (stored-file xdg-env file)
"Try to get FILE stored either in XDG-ENV or the home directory." "Try to get FILE stored either in XDG-ENV or the home directory."
(let ((xdg (getenv xdg-env)) (let ((xdg (getenv xdg-env))
(home (getenv "HOME")) (stored-file (string-append
(result #f)) (getenv "HOME") "/.undone/" file)))
(cond (unless (or (file-exists? stored-file) (not xdg))
(xdg (set! stored-file (string-append xdg "/undone/" file)))
(let ((xdg-stored-file (string-append xdg "/undone/" file))) stored-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))
(define (config-file file) (define (config-file file)
"Try to get FILE from the configuration file location." "Try to get FILE from the configuration file location."