[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-users] using mmap files as strings?

From: Alan Post
Subject: [Chicken-users] using mmap files as strings?
Date: Thu, 21 Oct 2010 15:01:10 -0600

I have the following file:

<++> mmap.scm
(use posix)
(use lolevel)

(let* ((fd (file-open "mmap.scm" (+ open/rdonly open/nonblock)))
       (size (file-size fd))
       (mmap (map-file-to-memory #f size prot/read (+ map/file map/shared) fd))
       (buf  (memory-mapped-file-pointer mmap)))
  (write fd)
  (write size)
  (write mmap)
  (write buf)
  (write (pointer-s8-ref buf))
  (write (integer->char (pointer-s8-ref buf)))

Which opens itself as an mmap and reads the first byte.  The output

<++> csc -o mmap mmap.scm && ./mmap
#<pointer 0x8818c000>

So far so good, that is what I would expect.  I'd like to work with
an mmap buffer like a string.  Is it possible to create an object
that will treat the mmap area as a string that I can run regular
string operations on without copying the mmap buffer?  I'm
specifically interested in running regular expressions across the
mmap space.

.i ko djuno fi le do sevzi

reply via email to

[Prev in Thread] Current Thread [Next in Thread]