Class FileCompressor
Since C# only has GZipStream until .NET 4.0, we are forced to implement our own packing system for artifact files. We compact all artifacts into a single GZip Stream with the header before the file name and contents. The header contains the file name length and file length (in bytes).
Namespace: UnityEditor.Build.Pipeline.Utilities
Syntax
public class FileCompressor
Methods
Compress(String, String)
Compresses all artifacts located at a specified directory.
Declaration
public static bool Compress(string directoryPath, string archiveFilePath)
Parameters
Type | Name | Description |
---|---|---|
String | directoryPath | The directory containing the artifacts. |
String | archiveFilePath | The file path at which the archive will be created. |
Returns
Type | Description |
---|---|
Boolean | Returns true if the directory was found and compressed. Returns false otherwise. |
Decompress(String, String)
Extracts all artifacts compressed in an archive.
Declaration
public static bool Decompress(string archiveFilePath, string directoryPath)
Parameters
Type | Name | Description |
---|---|---|
String | archiveFilePath | The archive to decompress. |
String | directoryPath | The path where the extracted artifacts will be stored. |
Returns
Type | Description |
---|---|
Boolean | Returns true if the archive was found and decompressed. Returns false otherwise. |