# cteate a GDS file
f <- createfn.gds("test.gds")
set.seed(1000)
rawval <- as.raw(rep(0:99, 50))
add.gdsn(f, "label", NULL)
add.gdsn(f, "raw", rawval)
closefn.gds(f)
##
f <- openfn.gds("test.gds")
diagnosis.gds(f)
diagnosis.gds(f$root)
diagnosis.gds(index.gdsn(f, "label"))
diagnosis.gds(index.gdsn(f, "raw"))
closefn.gds(f)
## remove fragments
cleanup.gds("test.gds")
##
f <- openfn.gds("test.gds")
diagnosis.gds(f$root)
diagnosis.gds(index.gdsn(f, "label"))
(adr <- diagnosis.gds(index.gdsn(f, "raw")))
closefn.gds(f)
## read binary data directly
f <- file("test.gds", "rb")
dat <- NULL
for (i in seq_len(length(adr$data$chunk_offset)))
{
seek(f, adr$data$chunk_offset[i])
dat <- c(dat, readBin(f, "raw", adr$data$chunk_size[i]))
}
identical(dat, rawval) # should be TRUE
close(f)
# delete the temporary file
unlink("test.gds", force=TRUE)
Run the code above in your browser using DataLab