From fbea00fb660ce1881364954843f632a07cce064a Mon Sep 17 00:00:00 2001 From: Jaidyn Levesque <10477760+JadedCtrl@users.noreply.github.com> Date: Mon, 2 Jan 2023 09:38:48 -0600 Subject: [PATCH] Rename , now returns attr value --- xattr.scm | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/xattr.scm b/xattr.scm index a7f7e6a..344e367 100644 --- a/xattr.scm +++ b/xattr.scm @@ -16,7 +16,7 @@ ;; (module xattr - (get-xattr set-xattr remove-xattr list-xattr) + (get-xattr set-xattr remove-xattr list-xattrs) (import scheme (chicken base) (chicken foreign) (chicken memory) @@ -43,15 +43,15 @@ ;; The direct foreign binding for `list_xattr` -(define list-xattr-foreign +(define list-xattrs-foreign (foreign-lambda (c-pointer char) "list_xattr" c-string (c-pointer ssize_t) (c-pointer int))) -;; Wrapper around list-xattr-foreign, which throws exceptions and such. -(define (list-xattr path) +;; Wrapper around list-xattrs-foreign, which throws exceptions and such. +(define (list-xattrs path) (let-location ([error-code int] [length ssize_t]) - (let ([list-pointer (list-xattr-foreign path (location length) (location error-code))] + (let ([list-pointer (list-xattrs-foreign path (location length) (location error-code))] [exception (or (getxattr-exception error-code) (stat-exception error-code))]) (if exception @@ -84,12 +84,13 @@ ;; Wrapper around remove-xattr-foreign, blah blah (define (remove-xattr path attr) - (let* ([error-code (remove-xattr-foreign path attr)] + (let* ([value (get-xattr path attr)] + [error-code (remove-xattr-foreign path attr)] [exception (or (getxattr-exception error-code) (stat-exception error-code))]) (if exception (signal exception) - attr))) + value))) ;; TODO: These exception functions should be constructed with a macro and a simple