Learn R Programming

gdsfmt (version 1.8.3)

diagnosis.gds: Diagnose the GDS file

Description

Diagnose the GDS file and data information.

Usage

diagnosis.gds(gds)

Arguments

gds
an object of class gdsn.class or gds.class

Value

A list with stream and chunk information.If gds is a "gds.class" object (i.e., a GDS file), the function returns a list with components, like:
stream
summary of byte stream
log
event log records
If gds is a "gdsn.class" object, the function returns a list with components, like:
head
total_size, chunk_offset, chunk_size
data
total_size, chunk_offset, chunk_size
...

References

http://github.com/zhengxwen/gdsfmt

Examples

Run this code
# 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