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
(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