[racket] Socket and character resp. block device file
At Mon, 6 Jan 2014 13:47:30 +0100, Manfred Lotz wrote:
> On Mon, 6 Jan 2014 10:32:49 +0100
> Manfred Lotz <manfred.lotz at arcor.de> wrote:
>
> > I was to quick to state this is a solution as it is not a good idea if
> > for example a socket file will be shown as a duplicate of normal file
> > having size zero.
> >
> > For the time being I guess I have to look how to implement it using C
> > stat call from Racket.
> >
> >
>
> To get into I tried the example in 'Indide Racket C API'/Overview
>
> I got:
> compiled
> compiled/native
> compiled/native/amd64-linux
> compiled/native/amd64-linux/3m
> compiled/native/amd64-linux/3m/hi_rkt.so
>
>
> Documentation says that it could be loaded like this:
>
> (require "hi.rkt")
>
>
> Now my question: What would the content of hi.rkt be?
The analogous source "hi.rkt" would be
#lang racket/base
(provide greeting)
(define greeting "hello")
but you don't actually create a "hi.rkt". Instead, the module loader
substitutes "hit_rkt.so".
Did you consider using `ffi/unsafe` instead of creating an extension?
Using the FFI library is usually much easier and more portable.
Unfortunately, the `stat` function, with its structure layout that
varies across platforms, is more difficult to call via `ffi/unsafe`,
but I would still do that instead of trying to write an extension.