Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

CFILE

Create a C-level handle for a file


Description

This function and class allow us to work with C-level FILE handles. The intent is to be able to pass these to libcurl as options so that it can read or write from or to the file. We can also do this with R connections and specify callback functions that manipulate these connections. But using the C-level FILE handle is likely to be significantly faster for large files.

The close method allows us to explicitly flush and close the file from within R.

Usage

CFILE(filename, mode = "r")

Arguments

filename

the name of the file on disk

mode

a string specifying how to open the file, read or write, text or binary.

Details

This is a simple interface to the C routine fopen.

Value

An object of class CFILE which is has a single slot name ref which is an external pointer holding the address of the FILE object in C.

Author(s)

Duncan Temple Lang

References

Man page for fopen

See Also

curlPerform and the readdata

Examples

## Not run: 
filename = system.file("tests", "amazon3.R", package = "RCurl")
f = CFILE(filename)

if(url.exists('http://s3.amazonaws.com/'))
  curlPerform(url = "http://s3.amazonaws.com/RRupload/duncan2",
              upload = TRUE,
              readdata = f@ref,
              infilesize = file.info(filename)[1, "size"])

## End(Not run)

RCurl

General Network (HTTP/FTP/...) Client Interface for R

v1.98-1.3
BSD_3_clause + file LICENSE
Authors
CRAN Team [ctb, cre] (de facto maintainer since 2013), Duncan Temple Lang [aut] (<https://orcid.org/0000-0003-0159-1546>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.