Archive
ReferencesThis class represents a complete file. Grasshopper2 files are essentially zip-archives containing a mixture of textual, binary and node-based entries.
Constructors
Fields
FileExtension
#Gets the file extension used for Grasshopper 2.0 files (minus the period). The extension is "ghz" which stands for GrassHopperZip(ped).
Properties
Indexers
Methods
AddData
#Add byte-array content to this archive.
AddDataUnsafe
#[EditorBrowsable(EditorBrowsableState.Advanced)]
public void AddDataUnsafe(string path, byte[] data)
Add byte-array content to this archive without copying. Only use this method if you know there is no chance of the byte array being shared.
AddRoot
#Add a root node to this archive.
AddText
#Add text content to this archive.
EnumerateAndExecute
#public void EnumerateAndExecute(TextMethod textMethod = null, DataMethod dataMethod = null, RootMethod rootMethod = null, NodeMethod nodeMethod = null, ItemMethod itemMethod = null)
Enumerate over all elements in this archive and invoke a delegate for each.
Parameters:
| textMethod (TextMethod = null) | Method for handling text data. |
| dataMethod (DataMethod = null) | Method for handling byte array data. |
| rootMethod (RootMethod = null) | Method for handling root nodes. |
| nodeMethod (NodeMethod = null) | Method for handling all nodes (including root nodes). |
| itemMethod (ItemMethod = null) | Method for handling item data. |
GetData
#Get the byte-array associated with the given path.
Parameters:
| path (string) | Path. |
Returns: Byte array.
GetDataUnsafe
#Get the byte-array associated with the given path. This method provides direct access to the internal array without duplication, so only use it if you're not going to modify this array.
Parameters:
| path (string) | Path. |
Returns: Bytes or null if no such byte path exists.
GetRoot
#Get the root node associated with the given path.
Parameters:
| path (string) | Path. |
Returns: Node at path.
GetText
#Try to get the text associated with the given path.
Parameters:
| path (string) | Path. |
Returns: Text or null if no such text path exists.
Read
#Read a file and store its contents in a new archive.
Read
#Read a file and store its contents in a new archive.
Parameters:
| filePath (string) | File to parse. |
Returns: Read archive.
Creates a new object that is a copy of the current instance.
Returns: A new object that is a copy of this instance.
Write
#An overload that writes this archive to a file on the disk, and reports the number of written bytes.