Changeset 9322 in project


Ignore:
Timestamp:
03/08/08 15:28:33 (12 years ago)
Author:
elf
Message:

stat predicates for file types

File:
1 edited

Legend:

Unmodified
Added
Removed
  • chicken/trunk/posixunix.scm

    r9316 r9322  
    196196#define C_islink            ((C_statbuf.st_mode & S_IFMT) == S_IFLNK)
    197197#define C_isreg             ((C_statbuf.st_mode & S_IFMT) == S_IFREG)
     198#define C_isdir             ((C_statbuf.st_mode & S_IFMT) == S_IFDIR)
     199#define C_ischr             ((C_statbuf.st_mode & S_IFMT) == S_IFCHR)
     200#define C_isblk             ((C_statbuf.st_mode & S_IFMT) == S_IFBLK)
     201#define C_isfifo            ((C_statbuf.st_mode & S_IFMT) == S_IFIFO)
     202#ifdef S_IFSOCK
     203#define C_issock            ((C_statbuf.st_mode & S_IFMT) == S_IFSOCK)
     204#else
     205#define C_issock            ((C_statbuf.st_mode & S_IFMT) == 0140000)
     206#endif
    198207
    199208#ifdef C_GNU_ENV
     
    781790  (##sys#stat fname #t 'symbolic-link?)
    782791  (foreign-value "C_islink" bool) )
     792
     793(let ((stat-type
     794         (lambda (name func)
     795             (lambda (fname)
     796                 (##sys#check-string fname name)
     797                 (##sys#stat fname #t name)
     798                 (foreign-value func bool)))))
     799    (set! stat-regular? (stat-type 'stat-regular? "C_isreg"))
     800    (set! stat-directory? (stat-type 'stat-directory? "C_isdir"))
     801    (set! stat-char-device? (stat-type 'stat-char-device? "C_ischr"))
     802    (set! stat-block-device? (stat-type 'stat-block-device? "C_isblk"))
     803    (set! stat-fifo? (stat-type 'stat-fifo? "C_isfifo"))
     804    (set! stat-symlink? (stat-type 'stat-symlink? "C_islink"))
     805    (set! stat-socket? (stat-type 'stat-socket? "C_issock")))
    783806
    784807(define set-file-position!              ; DEPRECATED
Note: See TracChangeset for help on using the changeset viewer.