mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-07-15 08:57:33 +02:00
Adding access(2) interface.
This commit is contained in:
parent
638ea1bf8a
commit
a579705b46
3 changed files with 16 additions and 0 deletions
|
@ -157,6 +157,15 @@
|
||||||
;;> is satisfied, and \scheme{#f} otherwise.
|
;;> is satisfied, and \scheme{#f} otherwise.
|
||||||
;;/
|
;;/
|
||||||
|
|
||||||
|
(define (file-is-readable? path) (zero? (file-access path access/read)))
|
||||||
|
(define (file-is-writable? path) (zero? (file-access path access/write)))
|
||||||
|
(define (file-is-executable? path) (zero? (file-access path access/execute)))
|
||||||
|
|
||||||
|
;;> File access tests. Returns true iff the current real UID and GID
|
||||||
|
;;> have the corresponding permissions on path. Equivalent to the
|
||||||
|
;;> test -r, -w, -x operators in sh.
|
||||||
|
;;/
|
||||||
|
|
||||||
;;> Equivalent to duplicating the file descriptor \var{old} to
|
;;> Equivalent to duplicating the file descriptor \var{old} to
|
||||||
;;> \var{new} and closing \var{old}.
|
;;> \var{new} and closing \var{old}.
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
open/create open/exclusive open/truncate
|
open/create open/exclusive open/truncate
|
||||||
open/append open/non-block
|
open/append open/non-block
|
||||||
file-lock file-truncate
|
file-lock file-truncate
|
||||||
|
file-is-readable? file-is-writable? file-is-executable?
|
||||||
lock/shared lock/exclusive lock/non-blocking lock/unlock
|
lock/shared lock/exclusive lock/non-blocking lock/unlock
|
||||||
is-a-tty?)
|
is-a-tty?)
|
||||||
(import (chibi) (chibi string))
|
(import (chibi) (chibi string))
|
||||||
|
|
|
@ -193,6 +193,12 @@
|
||||||
(define-c int (file-truncate "ftruncate")
|
(define-c int (file-truncate "ftruncate")
|
||||||
(port-or-fileno off_t))
|
(port-or-fileno off_t))
|
||||||
|
|
||||||
|
;; Used for file-is-readable?, file-is-writable?, file-is-executable?.
|
||||||
|
(define-c-const int (access/read "R_OK"))
|
||||||
|
(define-c-const int (access/write "W_OK"))
|
||||||
|
(define-c-const int (access/execute "X_OK"))
|
||||||
|
(define-c int (file-access "access") (string int))
|
||||||
|
|
||||||
;;> Applies the specified locking operation using flock(2) to the port
|
;;> Applies the specified locking operation using flock(2) to the port
|
||||||
;;> or file-descriptor.
|
;;> or file-descriptor.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue