mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-21 06:39:17 +02:00
adding directory-files to posix module
This commit is contained in:
parent
b49153dfdf
commit
6bd1bd3687
4 changed files with 29 additions and 4 deletions
|
@ -2,8 +2,9 @@
|
|||
(define-module (chibi posix)
|
||||
(export open-input-fd open-output-fd
|
||||
delete-file link-file symbolic-link rename-file
|
||||
create-directory delete-directory
|
||||
directory-files create-directory delete-directory
|
||||
current-seconds)
|
||||
(import (scheme))
|
||||
(include-shared "posix"))
|
||||
(include-shared "posix")
|
||||
(include "posix.scm"))
|
||||
|
||||
|
|
7
lib/chibi/posix.scm
Normal file
7
lib/chibi/posix.scm
Normal file
|
@ -0,0 +1,7 @@
|
|||
|
||||
(define (directory-files path)
|
||||
(let ((dir (opendir path)))
|
||||
(let lp ((res '()))
|
||||
(let ((file (readdir dir)))
|
||||
(if file (lp (cons (dirent-name file) res)) res)))))
|
||||
|
|
@ -2,6 +2,13 @@
|
|||
(c-system-include "sys/types.h")
|
||||
(c-system-include "time.h")
|
||||
(c-system-include "unistd.h")
|
||||
(c-system-include "dirent.h")
|
||||
|
||||
(define-c-struct DIR
|
||||
finalizer: closedir)
|
||||
|
||||
(define-c-struct dirent
|
||||
(string d_name dirent-name))
|
||||
|
||||
(define-c input-port (open-input-fd fdopen) (int (value "r")))
|
||||
(define-c output-port (open-output-fd fdopen) (int (value "w")))
|
||||
|
@ -11,11 +18,21 @@
|
|||
(define-c errno (symbolic-link-file symlink) (string string))
|
||||
(define-c errno (rename-file rename) (string string))
|
||||
|
||||
;; (define-c string (current-directory getcwd) ())
|
||||
(define-c errno (create-directory mkdir) (string int))
|
||||
(define-c errno (delete-directory rmdir) (string))
|
||||
|
||||
(define-c (free DIR) opendir (string))
|
||||
(define-c dirent readdir (DIR))
|
||||
|
||||
(define-c int (duplicate-fd dup) (int))
|
||||
;;(define-c errno pipe ((array int 2)))
|
||||
|
||||
(define-c pid_t fork ())
|
||||
;; (define-c pid_t wait ((result pointer int)))
|
||||
;; (define-c void exit (int))
|
||||
;; (define-c int (execute execvp) (string (array string null)))
|
||||
|
||||
;;(define-c errno pipe ((result array int 2)))
|
||||
|
||||
(define-c time_t (current-seconds time) ((value NULL)))
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@
|
|||
(memq type '(short int long)))
|
||||
|
||||
(define (unsigned-int-type? type)
|
||||
(memq type '(unsigned-short unsigned-int unsigned-long size_t)))
|
||||
(memq type '(unsigned-short unsigned-int unsigned-long size_t pid_t)))
|
||||
|
||||
(define (int-type? type)
|
||||
(or (signed-int-type? type) (unsigned-int-type? type)))
|
||||
|
|
Loading…
Add table
Reference in a new issue