[racket] Socket and character resp. block device file

From: Manfred Lotz (manfred.lotz at arcor.de)
Date: Mon Jan 6 16:08:29 EST 2014

Ok, finally using FFI works fine.


I implemented:

(define (socket-exists? f)
  (mode-exists f S_IFSOCK))

(define (pipe-exists? f)
  (mode-exists f S_IFIFO))

(define (block-device-exists? f)
  (mode-exists f S_IFBLK))

(define (character-device-exists? f)
  (mode-exists f S_IFCHR))

(define (regular-file-exists? f)
  (define s (make-STAT 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0))
  (if (zero? (__xstat64  1 f s))
      (not (or (is_type (STAT-mode_t s) S_IFSOCK)
               (is_type (STAT-mode_t s) S_IFIFO)
               (is_type (STAT-mode_t s) S_IFBLK)
               (is_type (STAT-mode_t s) S_IFCHR)))
      (error "Could not get stat for file")))



Could such functions be added to Racket which would be the proper
solution in my opinion?

As link-exists? does already exist all the machinery is already there so
that adding it in src/racket/src/file.c is pretty easy.


-- 
Manfred






Posted on the users mailing list.