Rename , now returns attr value

This commit is contained in:
Jaidyn Ann 2023-01-02 09:38:48 -06:00
parent c799d7a37c
commit fbea00fb66

View File

@ -16,7 +16,7 @@
;; ;;
(module xattr (module xattr
(get-xattr set-xattr remove-xattr list-xattr) (get-xattr set-xattr remove-xattr list-xattrs)
(import scheme (import scheme
(chicken base) (chicken foreign) (chicken memory) (chicken base) (chicken foreign) (chicken memory)
@ -43,15 +43,15 @@
;; The direct foreign binding for `list_xattr` ;; 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))) (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. ;; Wrapper around list-xattrs-foreign, which throws exceptions and such.
(define (list-xattr path) (define (list-xattrs path)
(let-location ([error-code int] (let-location ([error-code int]
[length ssize_t]) [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) [exception (or (getxattr-exception error-code)
(stat-exception error-code))]) (stat-exception error-code))])
(if exception (if exception
@ -84,12 +84,13 @@
;; Wrapper around remove-xattr-foreign, blah blah ;; Wrapper around remove-xattr-foreign, blah blah
(define (remove-xattr path attr) (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) [exception (or (getxattr-exception error-code)
(stat-exception error-code))]) (stat-exception error-code))])
(if exception (if exception
(signal exception) (signal exception)
attr))) value)))
;; TODO: These exception functions should be constructed with a macro and a simple ;; TODO: These exception functions should be constructed with a macro and a simple