by david-given · 10y ago · 0 comments
I'd vastly prefer the symbolic forms (and am slightly surprised that the kernel source has raw octal in it at all). Although I wouldn't have tried to implement the change as a thousand separate patches...
For an alternative symbolic approach, here is how it is done in Lisp, thanks to SETF (and the OSICAT library).
(file-permissions #P"/tmp/file")
NIL
(setf (file-permissions #P"/tmp/file")
'(:user-read :group-read :other-read))
... or
(nix:chmod #P"/tmp/file" #o444)
By the magic of SETF, you can now use all other macros which modify a place: (push :user-write (file-permissions #P"/tmp/file"))
And thus: (file-permissions #P"/tmp/file")
=> (:USER-READ :USER-WRITE :GROUP-READ :OTHER-READ)