Table of Contents

Class NodeFactory

Namespace
Yarhl.FileSystem
Assembly
Yarhl.dll

Node factory.

public static class NodeFactory
Inheritance
NodeFactory
Inherited Members

Methods

CreateContainer(string)

Creates a new Node with a new NodeContainer format.

public static Node CreateContainer(string name)

Parameters

name string

Node name.

Returns

Node

The new node.

CreateContainersForChild(Node, string, Node)

Creates the missing parent nodes to contain the child and add it.

public static void CreateContainersForChild(Node root, string path, Node child)

Parameters

root Node

The root node that will contain the nodes.

path string

The path for the child. It doesn't contain the root or child names.

child Node

The child to add to root with the path.

FromArray(string, byte[])

Creates a Node with a binary format containing the array.

public static Node FromArray(string name, byte[] data)

Parameters

name string

The name of the node.

data byte[]

The data for the binary format.

Returns

Node

The new node.

Exceptions

ArgumentNullException

The name is null or empty, the data is null.

FromArray(string, byte[], int, int)

Creates a Node with a binary format containing a part of the array.

public static Node FromArray(string name, byte[] data, int offset, int length)

Parameters

name string

The name of the node.

data byte[]

The data for the binary format.

offset int

The offset to start the data of the node.

length int

The number of bytes for the node's data.

Returns

Node

The new node.

Exceptions

ArgumentNullException

The name is null or empty, the data is null.

FromDirectory(string, Func<string, bool>, string, bool, FileOpenMode)

Creates a Node containing all the files from the directory.

public static Node FromDirectory(string dirPath, Func<string, bool> filter, string nodeName, bool subDirectories = false, FileOpenMode mode = FileOpenMode.ReadWrite)

Parameters

dirPath string

Directory path.

filter Func<string, bool>

Filter for files in directory.

nodeName string

Node name.

subDirectories bool

If true it searchs recursively in subdirectories.

mode FileOpenMode

The mode to open the files.

Returns

Node

The container node.

FromDirectory(string, Func<string, bool>, FileOpenMode)

Creates a Node containing all the files from the directory.

public static Node FromDirectory(string dirPath, Func<string, bool> filter, FileOpenMode mode = FileOpenMode.ReadWrite)

Parameters

dirPath string

Directory path.

filter Func<string, bool>

Filter for files in directory.

mode FileOpenMode

The mode to open the files.

Returns

Node

The container node.

FromDirectory(string, string, string, bool, FileOpenMode)

Creates a Node containing all the files from the directory.

public static Node FromDirectory(string dirPath, string filter, string nodeName, bool subDirectories = false, FileOpenMode mode = FileOpenMode.ReadWrite)

Parameters

dirPath string

Directory path.

filter string

Filter for files in directory.

nodeName string

Node name.

subDirectories bool

If true it searchs recursively in subdirectories.

mode FileOpenMode

The mode to open the files.

Returns

Node

The container node.

FromDirectory(string, string, FileOpenMode)

Creates a Node containing all the files from the directory.

public static Node FromDirectory(string dirPath, string filter = "*", FileOpenMode mode = FileOpenMode.ReadWrite)

Parameters

dirPath string

Directory path.

filter string

Filter for files in directory.

mode FileOpenMode

The mode to open the files.

Returns

Node

The container node.

FromFile(string, string, FileOpenMode)

Creates a Node from a file.

public static Node FromFile(string filePath, string nodeName, FileOpenMode mode = FileOpenMode.ReadWrite)

Parameters

filePath string

File path.

nodeName string

Node name.

mode FileOpenMode

The mode to open the file.

Returns

Node

The node.

Remarks

Add the tag "FileInfo" with the file info status at the time it's created.

In the case of Windows Symlinks, it will be the status of the link file, not the target.

FromFile(string, FileOpenMode)

Creates a Node from a file.

public static Node FromFile(string filePath, FileOpenMode mode = FileOpenMode.ReadWrite)

Parameters

filePath string

File path.

mode FileOpenMode

The mode to open the file.

Returns

Node

The node.

FromMemory(string)

Creates a Node with a new stream from memory.

public static Node FromMemory(string name)

Parameters

name string

The name of the node.

Returns

Node

The new node.

FromStream(string, Stream)

Creates a Node from a stream.

public static Node FromStream(string name, Stream stream)

Parameters

name string

The name of the node.

stream Stream

The binary stream.

Returns

Node

The new node.

Remarks

It will take over the ownership of the stream argument, you should not dispose this stream argument.

FromSubstream(string, Stream, long, long)

Creates a Node from a part of a stream.

public static Node FromSubstream(string name, Stream source, long offset, long length)

Parameters

name string

The name of the node.

source Stream

The source / parent stream.

offset long

The offset in the source stream where the node starts.

length long

The length of the data in the node.

Returns

Node

The new node.

Remarks

This format creates an internal DataStream from the provided stream. It will take over the ownership of the stream argument, you should not dispose this argument, unless you are providing a DataStream that we won't take over in case you want to create more substreams.