Refactor doom-file-size

Change it throw an error if the file doesn't exist.
This commit is contained in:
Henrik Lissner 2019-11-10 01:32:58 -05:00
parent d3d51e32a2
commit 17b874dedd
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -169,8 +169,10 @@ single file or nested compound statement of `and' and `or' statements."
;;;###autoload ;;;###autoload
(defun doom-file-size (file &optional dir) (defun doom-file-size (file &optional dir)
"Returns the size of FILE (in DIR) in kilobytes." "Returns the size of FILE (in DIR) in bytes."
(when-let (file (file-exists-p! file dir)) (let ((file (expand-file-name file dir)))
(unless (file-exists-p file)
(error "Couldn't find file %S" file))
(unless (file-readable-p file) (unless (file-readable-p file)
(error "File %S is unreadable; can't acquire its filesize" (error "File %S is unreadable; can't acquire its filesize"
file)) file))