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
stringNode 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
NodeThe root node that will contain the nodes.
path
stringThe path for the child. It doesn't contain the root or child names.
child
NodeThe 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
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
stringThe name of the node.
data
byte[]The data for the binary format.
offset
intThe offset to start the data of the node.
length
intThe 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
stringDirectory path.
filter
Func<string, bool>Filter for files in directory.
nodeName
stringNode name.
subDirectories
boolIf true it searchs recursively in subdirectories.
mode
FileOpenModeThe 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
stringDirectory path.
filter
Func<string, bool>Filter for files in directory.
mode
FileOpenModeThe 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
stringDirectory path.
filter
stringFilter for files in directory.
nodeName
stringNode name.
subDirectories
boolIf true it searchs recursively in subdirectories.
mode
FileOpenModeThe 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
stringDirectory path.
filter
stringFilter for files in directory.
mode
FileOpenModeThe 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
stringFile path.
nodeName
stringNode name.
mode
FileOpenModeThe 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
stringFile path.
mode
FileOpenModeThe 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
stringThe 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
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
stringThe name of the node.
source
StreamThe source / parent stream.
offset
longThe offset in the source stream where the node starts.
length
longThe 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.