diff options
author | Arun Isaac | 2019-02-04 01:28:34 +0530 |
---|---|---|
committer | Arun Isaac | 2019-02-04 01:35:10 +0530 |
commit | 8892e1485d2157e0e9be8f337d1d2ff7b1a6c338 (patch) | |
tree | c085804c75afe5365d9adb1c09301eac25717bbf /exiftool.el | |
parent | 3a07dbcb975577734d4abf6d68e1ab83a01951bb (diff) | |
download | exiftool.el-8892e1485d2157e0e9be8f337d1d2ff7b1a6c338.tar.gz exiftool.el-8892e1485d2157e0e9be8f337d1d2ff7b1a6c338.tar.lz exiftool.el-8892e1485d2157e0e9be8f337d1d2ff7b1a6c338.zip |
Signal a file-missing error when file is not found.
* exiftool.el (exiftool--assert-file-exists): New function.
(exiftool-read, exiftool-copy, exiftool-write): Assert that file
arguments exist before operating on them.
* tests/exiftool-tests.el (read-file-not-found-test,
copy-file-not-found-test, write-file-not-found-test): New tests.
Diffstat (limited to 'exiftool.el')
-rw-r--r-- | exiftool.el | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/exiftool.el b/exiftool.el index a9495c5..3e5327b 100644 --- a/exiftool.el +++ b/exiftool.el @@ -1,7 +1,7 @@ ;;; exiftool.el --- Elisp wrapper around ExifTool -*- lexical-binding: t -*- ;; Elisp wrapper around ExifTool -;; Copyright (C) 2017 by Arun I +;; Copyright (C) 2017, 2019 by Arun I ;; ;; Author: Arun I <arunisaac@systemreboot.net> ;; Version: 0.3 @@ -77,6 +77,10 @@ exiftool command line application." "\n-execute\n") suffix)))))) +(defun exiftool--assert-file-exists (file) + (unless (file-exists-p file) + (signal 'file-missing file))) + (defun exiftool-read (file &rest tags) "Read TAGS from FILE, return an alist mapping TAGS to values. @@ -84,6 +88,7 @@ If a tag is not found, return an empty string \"\" as the value. If no TAGS are specified, read all tags from FILE. \(fn FILE TAG...)" + (exiftool--assert-file-exists file) (mapcar (lambda (line) (string-match "\\([^:]*\\): \\(.*\\)" line) @@ -105,6 +110,8 @@ value. If no TAGS are specified, read all tags from FILE. "Copy TAGS from SOURCE file to DESTINATION file. If no TAGS are specified, copy all tags from SOURCE." + (exiftool--assert-file-exists source) + (exiftool--assert-file-exists destination) (apply 'exiftool-command "-m" "-overwrite_original" "-tagsFromFile" source @@ -123,6 +130,7 @@ pairs. Specifying the empty string \"\" for VALUE deletes that TAG. \(fn FILE (TAG . VALUE)...)" + (exiftool--assert-file-exists file) (apply 'exiftool-command "-m" "-overwrite_original" (append |