From be4a61a8651e72984715fca3c019870d9233d771 Mon Sep 17 00:00:00 2001 From: retropikzel Date: Mon, 29 Jun 2026 20:40:15 +0300 Subject: [PATCH] file-info work --- Makefile | 3 ++- srfi/170.scm | 18 +++++++++++++++++- srfi/170/test.scm | 4 ++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 61152f4..fb07354 100644 --- a/Makefile +++ b/Makefile @@ -24,10 +24,11 @@ DOCKER_TAG=head all: package package: srfi/${SRFI}/LICENSE srfi/${SRFI}/VERSION + echo "
$$(cat README.md)
" > README.html snow-chibi package \ --version=${VERSION} \ --authors=${AUTHOR} \ - --doc-from-scribble=1 \ + --doc=${README} \ --description="${DESCRIPTION}" \ ${SRFI_FILE} diff --git a/srfi/170.scm b/srfi/170.scm index b98f810..a5a849b 100644 --- a/srfi/170.scm +++ b/srfi/170.scm @@ -4,6 +4,7 @@ "string.h" "dirent.h" "sys/stat.h" + "sys/statvfs.h" "sys/types.h" "unistd.h" "pwd.h" @@ -155,6 +156,21 @@ (cond ((> handle 0) (c-close handle) #f) (else #t)))) +(define-c-struct-type timespec-struct '((tv_sec long) (tv_nsec long))) +(define-c-struct-type stat-struct + '((st_dev int) + (st_ino uint) + (st_mode uint) + (st_nlink int) + (st_uid uint) + (st_gid uint) + (st_rdev int) + (st_size int) + (st_blksize int) + (st_blocks int) + (st_atim timespec-struct) + (st_mtim timespec-struct) + (st_ctim timespec-struct))) ;;> The file-info procedure returns a file-info record containing useful ;;> information about a file. If the follow? flag is true the procedure will ;;> follow symlinks and report on the file to which they refer. If follow? is @@ -164,7 +180,7 @@ (when (port? fname/port) (error "file-info implementation does not support ports as arguments")) (let* ((fname-pointer (string->c-bytevector fname/port)) - (stat-pointer (make-c-bytevector 256)) + (stat-pointer (make-c-bytevector (c-type-size stat-struct))) (result (if follow? (c-stat fname-pointer stat-pointer) (c-lstat fname-pointer stat-pointer))) diff --git a/srfi/170/test.scm b/srfi/170/test.scm index 7fd97f9..b0aaea8 100644 --- a/srfi/170/test.scm +++ b/srfi/170/test.scm @@ -10,6 +10,10 @@ (test-assert (number? niceness)) (test-assert (> niceness 0)) +(define fi (file-info "/tmp" #f)) +(write (file-info-directory? fi)) +(newline) + #| (define tmp-dir "/tmp/foreign-c-srfi-170")