[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] Full fstat?
From: |
Kon Lovett |
Subject: |
Re: [Chicken-users] Full fstat? |
Date: |
Sun, 14 Jan 2007 09:40:50 -0800 |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Jan 13, 2007, at 11:40 PM, Robin Lee Powell wrote:
On Sat, Jan 13, 2007 at 01:09:39AM -0800, Robin Lee Powell wrote:
(I haven't actually tested this yet, but:)
The docs for file-stat
(http://chicken.wiki.br/Unit%20posix#file-stat) say that it
returns only parts of C fstat; I need all of it. In particular, I
need both dev and inode numbers. How can I get that from within
Chicken?
I've now tested this and yeah, no dev number for me. :-(
But inode is returned.
Suggestions?
-Robin, who is scared of FFI stuff.
Well, for the near term you must embrace your fear.
#>
#include <sys/types.h>
#include <sys/stat.h>
struct stat C_statbuf;
<#
(define-foreign-variable _stat_st_dev unsigned-int "C_statbuf.st_dev")
(define-foreign-variable _stat_st_ino unsigned-int "C_statbuf.st_ino")
(define-foreign-variable _stat_st_nlink unsigned-int
"C_statbuf.st_nlink")
(define-foreign-variable _stat_st_gid unsigned-int "C_statbuf.st_gid")
(define-foreign-variable _stat_st_size unsigned-int "C_statbuf.st_size")
(define-foreign-variable _stat_st_mtime double "C_statbuf.st_mtime")
(define-foreign-variable _stat_st_atime double "C_statbuf.st_atime")
(define-foreign-variable _stat_st_ctime double "C_statbuf.st_ctime")
(define-foreign-variable _stat_st_uid unsigned-int "C_statbuf.st_uid")
(define-foreign-variable _stat_st_mode unsigned-int "C_statbuf.st_mode")
(define file-stat
(let ([c-fstat (foreign-lambda* int ((int fd)) "C_return(fstat(fd,
&C_statbuf));")])
(lambda (fd)
(if (fx< (c-fstat fd) 0)
(posix-error #:file-error 'file-stat "cannot access file" fd)
(vector
_stat_st_ino _stat_st_mode _stat_st_nlink
_stat_st_uid _stat_st_gid _stat_st_size
_stat_st_atime _stat_st_ctime _stat_st_mtime
_stat_st_dev) ) ) ) )
Best Wishes,
Kon
_______________________________________________
Chicken-users mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/chicken-users
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Darwin)
iEYEARECAAYFAkWqayIACgkQJJNoeGe+5O4CUQCfamdkzuLUG24t1tjfGFYrN+aQ
4+8An12x33z+Fol0y2lpvW76lfVRdGJ3
=AbLf
-----END PGP SIGNATURE-----