addfolder.gdsn {gdsfmt} | R Documentation

## Add a folder to the GDS node

### Description

Add a directory or a virtual folder to the GDS node.

### Usage

    addfolder.gdsn(node, name, type=c("directory", "virtual"), gds.fn="",
        replace=FALSE, visible=TRUE)

### Arguments

`node` | an object of class `gdsn.class` or `gds.class`
`name` | the variable name; if it is not specified, a temporary name is assigned
`type` | "directory" (default) – create a directory of GDS node; "virtual" – create a virtual folder linking another GDS file by mapping all of the content to this virtual folder
`gds.fn` | the name of another GDS file; it is applicable only if `type="virtual"`
`replace` | if `TRUE`, replace the existing variable silently if possible
`visible` | `FALSE` – invisible/hidden, except `print(, all=TRUE)`

### Value

An object of class `gdsn.class`.

### Author(s)

Xiuwen Zheng

### References

http://github.com/zhengxwen/gdsfmt

### See Also

`add.gdsn`, `addfile.gdsn`

### Examples

    # create the first GDS file
    f1 <- createfn.gds("test1.gds")

    add.gdsn(f1, "NULL")
    addfolder.gdsn(f1, "dir")
    add.gdsn(f1, "int", 1:100)
    f1

    # open the GDS file
    closefn.gds(f1)

    ##############################################

    # create the second GDS file
    f2 <- createfn.gds("test2.gds")

    add.gdsn(f2, "int", 101:200)

    # link to the first file
    addfolder.gdsn(f2, "virtual_folder", type="virtual", gds.fn="test1.gds")

    f2

    # open the GDS file
    closefn.gds(f2)

    ##############################################

    # open the second file (writable)
    (f <- openfn.gds("test2.gds", FALSE))
    # +    [  ]
    # |--+ int   { Int32 100, 400 bytes }
    # |--+ virtual_folder   [ --> test1.gds ]
    # |  |--+ NULL
    # |  |--+ dir   [  ]
    # |  |--+ int   { Int32 100, 400 bytes }

    read.gdsn(index.gdsn(f, "int"))
    read.gdsn(index.gdsn(f, "virtual_folder/int"))
    add.gdsn(index.gdsn(f, "virtual_folder/dir"), "nm", 1:10)

    f

    # open the GDS file
    closefn.gds(f)

    ##############################################
    # open 'test1.gds', there is a new variable "dir/nm"

    (f <- openfn.gds("test1.gds"))
    closefn.gds(f)

    ##############################################
    # remove 'test1.gds'

    file.remove("test1.gds")

    ## Not run:
    (f <- openfn.gds("test2.gds"))
    # +    [  ]
    # |--+ int   { Int32 100, 400 bytes }
    # |--+ virtual_folder   [ -X- test1.gds ]

    closefn.gds(f)
    ## End(Not run)

    # delete the temporary file
    unlink("test.gds", force=TRUE)

[Package gdsfmt version 1.30.0 Index]