>>>>> "t" == ts  <decoux / moulon.inra.fr> writes:

t>  The big problem I think is with methods which can change RSTRING(str)->len

 You can make it work, but this need modification in ruby (mainly string.c)
and I don't like this :-(

pigeon% cat b.b
1234567890
pigeon% 

pigeon% ls -alg b.b
-rw-r--r--    1 ts       ts             11 Dec 21 14:43 b.b
pigeon% 

pigeon% cat b.rb
#!/tmp/local/bin/ruby
require "mmap"
a = String.mmap("b.b", "rw")
puts a.gsub!(/./, '(\&)')
pigeon%

pigeon% b.rb
(1)(2)(3)(4)(5)(6)(7)(8)(9)(0)
pigeon% 

pigeon% ls -al b.b
-rw-r--r--    1 ts       ts             31 Dec 21 14:49 b.b
pigeon% 

t>  Now try with File#mmap and you'll see the result :-)

 For File#mmap it seems to work if you open a new fd (ruby store the
 pathname of the file) and don't try to re-use fh->f, i.e.

    GetOpenFile(obj, fh);
    if ((fd = open(fh->path, smode)) == -1) {
	rb_raise(rb_eTypeError, "open");
    }


Guy Decoux