Commits

Walton Hoops committed 9f00ef7

throw an error if tagfile is invalid

Comments (0)

Files changed (1)

 (defcfun (free "taglib_free") :void
   (str :pointer))
 
-(defcfun (file-new "taglib_file_new") :pointer
-  (filename :string))
-
 (defcfun (file-free "taglib_file_free") :void
   (file :pointer))
 
 (defcfun (file-is-valid "taglib_file_is_valid") :boolean
   (file :pointer))
 
+(defun file-new (file)
+  (let ((ptr (foreign-funcall "taglib_file_new" :string file :pointer)))
+    (cond ((null-pointer-p ptr) (error (format nil "Invalid tagfile: ~s" file)))
+	  ((not (file-is-valid ptr)) (error (format nil "Invalid tagfile: ~s" file)))
+	  (t ptr))))
+
 (defcfun (file-tag "taglib_file_tag") :pointer
   (file :pointer))