Learn R Programming

adfExplorer (version 2.0.3)

adf_file_con: Open a connection to a file on a virtual ADF device

Description

Open a connection to a file on a virtual ADF device. The created connection (if valid) should be accepted by any R function that reads from or writes to a connection, such as readLines(), writeLines(), readBin(), writeBin(), etc.

Usage

adf_file_con(x, ..., writable = FALSE)

# S3 method for adf_device adf_file_con(x, path, ..., writable = FALSE)

# S3 method for character adf_file_con.adf_device(x, path, ..., writable = FALSE)

# S3 method for virtual_path adf_file_con(x, ..., writable = FALSE)

Value

Returns an R connection that can be handled by any function that accepts a connection for reading or writing. Remember to call close() after use.

Arguments

x

Either a connection to a virtual ADF device created with connect_adf(), or a virtual_path created with virtual_path().

...

Ignored.

writable

A logical value. When TRUE the connection can be used to write to the file on the virtual device. When FALSE it can only be used to read. Note that a writeable connection can only be setup on a virtual device that is not write protected.

path

Only required when x is a virtual device of class adf_device. In that case path should be a character string representing the path to the file on the virtual device. See also vignette("virtual_paths").

Author

Pepijn de Vries

Examples

Run this code
## First setup a connection to a virtual device
adz_file <- system.file("example.adz", package = "adfExplorer")
my_device <- connect_adf(adz_file)

## Open a connection to a file on the virtual device
fcon <- adf_file_con(my_device, "DF0:s/startup-sequence")

## Read from the file
my_startup <- readLines(fcon, warn = FALSE)

## Close the file
close(fcon)

## Close the virtual device
close(my_device)

Run the code above in your browser using DataLab