mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-21 22:59:16 +02:00
Providing read-link utility.
This commit is contained in:
parent
fe80e56db9
commit
9d1f046385
3 changed files with 12 additions and 0 deletions
|
@ -162,3 +162,12 @@
|
|||
(define (renumber-file-descriptor old new)
|
||||
(and (duplicate-file-descriptor-to old new)
|
||||
(close-file-descriptor old)))
|
||||
|
||||
;;> Returns the path the symbolic link \var{file} points to, or
|
||||
;;> \scheme{#f} on error.
|
||||
|
||||
(define (read-link file)
|
||||
(let* ((buf (make-string 512))
|
||||
(res (readlink file buf 512)))
|
||||
(and (positive? res)
|
||||
(substring buf 0 res))))
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
create-directory create-directory*
|
||||
current-directory change-directory with-directory
|
||||
open open-pipe make-fifo
|
||||
read-link
|
||||
file-status file-link-status
|
||||
file-device file-inode
|
||||
file-mode file-num-links
|
||||
|
|
|
@ -66,6 +66,8 @@
|
|||
(define-c errno fstat (int (result stat)))
|
||||
(define-c errno (file-link-status "lstat") (string (result stat)))
|
||||
|
||||
(define-c int readlink (string string int))
|
||||
|
||||
;; Creates a new input-port from the file descriptor \var{int}.
|
||||
|
||||
;; (define-c input-port (open-input-file-descriptor "fdopen")
|
||||
|
|
Loading…
Add table
Reference in a new issue