openfn.gds(filename, readonly=TRUE, allow.duplicate=FALSE, allow.fork=FALSE)
TRUE
, the file is opened read-only;
otherwise, it is allowed to write data to the fileTRUE
, it is allowed to open a GDS file
with read-only mode when it has been opened in the same R sessionTRUE
for parallel environment using forking,
see detailsgds.class
.
gdsn.class
,
the root of hierachical structurereadonly=FALSE
, for writing). To create a new GDS file, use
createfn.gds
instead.If the file is opened read-only, all data in the file are not allowed to be changed, including hierachical structure, variable names, data fields, etc.
mclapply
and mcmapply
in
the R package parallel
rely on unix forking. However, the forked child
process inherits copies of the parent's set of open file descriptors. Each
file descriptor in the child refers to the same open file description as the
corresponding file descriptor in the parent. This means that the two
descriptors share open file status flags, current file offset, and
signal-driven I/O attributes. The sharing of file description can cause a
serious problem (wrong reading, even program crashes), when child processes
read or write the same GDS file simultaneously.
allow.fork=TRUE
adds additional file operations to avoid any
conflict using forking. The current implementation does not support writing
in forked processes.
createfn.gds
, closefn.gds
# cteate a GDS file
f <- createfn.gds("test.gds")
# add a list to "test.gds"
node <- add.gdsn(f, name="list", val=list(x=c(1,2), y=c("T","B","C"), z=TRUE))
# close
closefn.gds(f)
# open the same file
f <- openfn.gds("test.gds")
# read
(node <- index.gdsn(f, "list"))
read.gdsn(node)
# close the GDS file
closefn.gds(f)
# delete the temporary file
unlink("test.gds", force=TRUE)
Run the code above in your browser using DataLab