From ripley@stats.ox.ac.uk  Fri Jun 30 07:22:51 2000
From: ripley@stats.ox.ac.uk (Prof Brian D Ripley)
Date: Fri, 30 Jun 2000 07:22:51 +0100 (BST)
Subject: [Rd] Binary file functions in R
In-Reply-To: <395c1fdc.944518@julian.uwo.ca>
Message-ID: <Pine.GSO.4.05.10006300717310.3250-100000@auk.stats>

On Fri, 30 Jun 2000, Duncan Murdoch wrote:

> I've put together the first version of "Rstreams", a package that
> allows binary access to files.  This version is for Windows only.
> You can pick it up as
> <http://www.stats.uwo.ca/faculty/murdoch/software/rstreams.zip>.
> Comments are welcome!
> 
> Some known problems:
> 
> I tried to set it up as a package, but couldn't figure out from the
> documentation where the .DLL should go.  It's sitting in the src
> directory for now.

It is not intended to be in the source of a package. Once the package is
compiled, the DLL goes in the libs directory.

> There are other things wrong with the organization as a package; R
> says "no R code found" when I try to attach it.  If you want to use
> it, you'll have to source the Rstreams.R file and dyn.load the DLL
> yourself.

Yes, you need to compile the package before using library() on it
(and that converts the help files too).

> I used the .C() interface to external functions, but I'm not sure how
> it handles character vectors being returned from DLLs.  I'm sticking
> string pointers into the result vector, which is likely to cause
> memory problems, since I don't use Ralloc to allocate the strings.
> How are you supposed to return a string value?  (This only applies to
> the print method; it needs to find out the filename.  The readchar
> method pre-allocates the space that's needed and uses that.)

You do need to use Ralloc to allocate storage for strings.  The .C
interface copies the strings on the way in and out, so the memory
needs to be de-allocated after the copy.


-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


[Rd] Binary file functions in R
Prof Brian D Ripley