|
Lean
$LEAN_TAG$
|
Compression class manages the opening and extraction of compressed files (zip, tar, tar.gz). More...
Static Public Member Functions | |
| static bool | ZipData (string zipPath, Dictionary< string, string > filenamesAndData) |
| Create a zip file of the supplied file names and string data source More... | |
| static bool | ZipData (string zipPath, IEnumerable< KeyValuePair< string, byte[]>> filenamesAndData) |
| Create a zip file of the supplied file names and data using a byte array More... | |
| static bool | ZipData (string zipPath, string zipEntry, IEnumerable< string > lines) |
| Zips the specified lines of text into the zipPath More... | |
| static bool | ZipCreateAppendData (string path, string entry, string data, bool overrideEntry=false) |
| Append the zip data to the file-entry specified. More... | |
| static bool | ZipCreateAppendData (string path, string entry, byte[] data, bool overrideEntry=false) |
| Append the zip data to the file-entry specified. More... | |
| static Dictionary< string, string > | UnzipData (byte[] zipData, Encoding encoding=null) |
| Uncompress zip data byte array into a dictionary string array of filename-contents. More... | |
| static async Task< Dictionary< string, string > > | UnzipDataAsync (Stream stream, Encoding encoding=null) |
| Uncompress zip data byte array into a dictionary string array of filename-contents. More... | |
| static byte[] | ZipBytes (byte[] bytes, string zipEntryName) |
| Performs an in memory zip of the specified bytes More... | |
| static async Task | ZipBytesAsync (Stream target, byte[] data, string zipEntryName, ZipArchiveMode? mode=null, CompressionLevel? compressionLevel=null) |
| Performs an in memory zip of the specified bytes in the target stream More... | |
| static async Task | ZipBytesAsync (Stream target, IEnumerable< KeyValuePair< byte[], string >> data, ZipArchiveMode? mode=null, CompressionLevel? compressionLevel=null) |
| Performs an in memory zip of the specified bytes in the target stream More... | |
| static async Task | ZipStreamsAsync (string target, IEnumerable< KeyValuePair< string, Stream >> data, ZipArchiveMode? mode=null, CompressionLevel? compressionLevel=null) |
| Performs an in memory zip of the specified stream in the target stream More... | |
| static async Task | ZipStreamsAsync (Stream target, IEnumerable< KeyValuePair< string, Stream >> data, ZipArchiveMode? mode=null, CompressionLevel? compressionLevel=null, bool leaveStreamOpen=false) |
| Performs an in memory zip of the specified stream in the target stream More... | |
| static string | UnGZip (string gzipFileName, string targetDirectory) |
| Extract .gz files to disk More... | |
| static string | Zip (string textPath, string zipEntryName, bool deleteOriginal=true) |
| Compress a given file and delete the original file. Automatically rename the file to name.zip. More... | |
| static void | Zip (string source, string destination, string zipEntryName, bool deleteOriginal) |
| Compresses the specified source file. More... | |
| static string | Zip (string textPath, bool deleteOriginal=true) |
| Compress a given file and delete the original file. Automatically rename the file to name.zip. More... | |
| static void | Zip (string data, string zipPath, string zipEntry) |
| Compress given data to the path given More... | |
| static bool | ZipDirectory (string directory, string destination, bool includeRootInZip=true) |
| Zips the specified directory, preserving folder structure More... | |
| static bool | Unzip (string zip, string directory, bool overwrite=false) |
| Unzips the specified zip file to the specified directory More... | |
| static void | ZipFiles (string destination, IEnumerable< string > files) |
| Zips all files specified to a new zip at the destination path More... | |
| static StreamReader | Unzip (string filename, out ZipFile zip) |
| Streams a local zip file using a streamreader. Important: the caller must call Dispose() on the returned ZipFile instance. More... | |
| static StreamReader | Unzip (string filename, string zipEntryName, out ZipFile zip) |
| Streams a local zip file using a streamreader. Important: the caller must call Dispose() on the returned ZipFile instance. More... | |
| static IEnumerable< KeyValuePair< string, List< string > > > | Unzip (string filename) |
| Streams the unzipped file as key value pairs of file name to file contents. NOTE: When the returned enumerable finishes enumerating, the zip stream will be closed rendering all key value pair Value properties unaccessible. Ideally this would be enumerated depth first. More... | |
| static IEnumerable< KeyValuePair< string, List< string > > > | Unzip (Stream stream) |
| Lazily unzips the specified stream More... | |
| static List< string > | ReadLines (string filename) |
| Streams each line from the first zip entry in the specified zip file More... | |
| static StreamReader | UnzipStreamToStreamReader (Stream zipstream) |
| Unzip a local file and return its contents via streamreader: More... | |
| static Stream | UnzipStream (Stream zipstream, out ZipFile zipFile, string entryName=null) |
| Unzip a stream that represents a zip file and return the first entry as a stream More... | |
| static List< string > | UnzipToFolder (byte[] zipData, string outputFolder) |
| Unzip the given byte array and return the created file names. More... | |
| static List< string > | UnzipToFolder (string zipFile) |
| Unzip a local file and return the created file names More... | |
| static void | UnTarFiles (string source, string destination) |
| Extracts all file from a zip archive and copies them to a destination folder. More... | |
| static void | UnTarGzFiles (string source, string destination) |
| Extract tar.gz files to disk More... | |
| static IEnumerable< KeyValuePair< string, byte[]> > | UnTar (Stream stream, bool isTarGz) |
| Enumerate through the files of a TAR and get a list of KVP names-byte arrays More... | |
| static IEnumerable< KeyValuePair< string, byte[]> > | UnTar (string source) |
| Enumerate through the files of a TAR and get a list of KVP names-byte arrays. More... | |
| static bool | ValidateZip (string path) |
| Validates whether the zip is corrupted or not More... | |
| static IEnumerable< string > | GetZipEntryFileNames (string zipFileName) |
| Returns the entry file names contained in a zip file More... | |
| static IEnumerable< string > | GetZipEntryFileNames (Stream zipFileStream) |
| Return the entry file names contained in a zip file More... | |
| static void | Extract7ZipArchive (string inputFile, string outputDirectory, int execTimeout=60000) |
| Extracts a 7-zip archive to disk, using the 7-zip CLI utility More... | |
Compression class manages the opening and extraction of compressed files (zip, tar, tar.gz).
QuantConnect's data library is stored in zip format locally on the hard drive.
Definition at line 40 of file Compression.cs.
|
static |
Create a zip file of the supplied file names and string data source
| zipPath | Output location to save the file. |
| filenamesAndData | File names and data in a dictionary format. |
Definition at line 60 of file Compression.cs.
|
static |
Create a zip file of the supplied file names and data using a byte array
| zipPath | Output location to save the file. |
| filenamesAndData | File names and data in a dictionary format. |
Definition at line 98 of file Compression.cs.
|
static |
Zips the specified lines of text into the zipPath
| zipPath | The destination zip file path |
| zipEntry | The entry name in the zip |
| lines | The lines to be written to the zip |
Definition at line 147 of file Compression.cs.
|
static |
Append the zip data to the file-entry specified.
| path | The zip file path |
| entry | The entry name |
| data | The entry data |
| overrideEntry | True if should override entry if it already exists |
Definition at line 178 of file Compression.cs.
|
static |
Append the zip data to the file-entry specified.
| path | The zip file path |
| entry | The entry name |
| data | The entry data |
| overrideEntry | True if should override entry if it already exists |
Definition at line 210 of file Compression.cs.
|
static |
Uncompress zip data byte array into a dictionary string array of filename-contents.
| zipData | Byte data array of zip compressed information |
| encoding | Specifies the encoding used to read the bytes. If not specified, defaults to ASCII |
Definition at line 240 of file Compression.cs.
|
static |
Uncompress zip data byte array into a dictionary string array of filename-contents.
| stream | Stream data of zip compressed information |
| encoding | Specifies the encoding used to read the bytes. If not specified, defaults to ASCII |
Definition at line 252 of file Compression.cs.
|
static |
Performs an in memory zip of the specified bytes
| bytes | The file contents in bytes to be zipped |
| zipEntryName | The zip entry name |
Definition at line 298 of file Compression.cs.
|
static |
Performs an in memory zip of the specified bytes in the target stream
| target | The target stream |
| data | The file contents in bytes to be zipped |
| zipEntryName | The zip entry name |
| mode | The archive mode |
| compressionLevel | The desired compression level |
Definition at line 314 of file Compression.cs.
|
static |
Performs an in memory zip of the specified bytes in the target stream
| target | The target stream |
| data | The file contents in bytes to be zipped |
| mode | The archive mode |
| compressionLevel | The desired compression level |
Definition at line 328 of file Compression.cs.
|
static |
Performs an in memory zip of the specified stream in the target stream
| target | The target stream |
| data | The file contents in bytes to be zipped |
| mode | The archive mode |
| compressionLevel | The desired compression level |
Definition at line 349 of file Compression.cs.
|
static |
Performs an in memory zip of the specified stream in the target stream
| target | The target stream |
| data | The file contents in bytes to be zipped |
| mode | The archive mode |
| compressionLevel | The desired compression level |
| leaveStreamOpen | True to leave the taget stream open |
Definition at line 367 of file Compression.cs.
|
static |
Extract .gz files to disk
| gzipFileName | |
| targetDirectory |
Definition at line 390 of file Compression.cs.
|
static |
Compress a given file and delete the original file. Automatically rename the file to name.zip.
| textPath | Path of the original file |
| zipEntryName | The name of the entry inside the zip file |
| deleteOriginal | Boolean flag to delete the original file after completion |
Definition at line 411 of file Compression.cs.
|
static |
Compresses the specified source file.
| source | The source file to be compressed |
| destination | The destination zip file path |
| zipEntryName | The zip entry name for the file |
| deleteOriginal | True to delete the source file upon completion |
Definition at line 425 of file Compression.cs.
|
static |
Compress a given file and delete the original file. Automatically rename the file to name.zip.
| textPath | Path of the original file |
| deleteOriginal | Boolean flag to delete the original file after completion |
Definition at line 466 of file Compression.cs.
|
static |
Compress given data to the path given
| data | Data to write to zip |
| zipPath | Path to write to |
| zipEntry | Entry to save the data as |
Definition at line 477 of file Compression.cs.
|
static |
Zips the specified directory, preserving folder structure
| directory | The directory to be zipped |
| destination | The output zip file destination |
| includeRootInZip | True to include the root 'directory' in the zip, false otherwise |
Definition at line 504 of file Compression.cs.
|
static |
Unzips the specified zip file to the specified directory
| zip | The zip to be unzipped |
| directory | The directory to place the unzipped files |
| overwrite | Flag specifying whether or not to overwrite existing files |
Definition at line 537 of file Compression.cs.
|
static |
Zips all files specified to a new zip at the destination path
Definition at line 579 of file Compression.cs.
|
static |
Streams a local zip file using a streamreader. Important: the caller must call Dispose() on the returned ZipFile instance.
| filename | Location of the original zip file |
| zip | The ZipFile instance to be returned to the caller |
Definition at line 616 of file Compression.cs.
|
static |
Streams a local zip file using a streamreader. Important: the caller must call Dispose() on the returned ZipFile instance.
| filename | Location of the original zip file |
| zipEntryName | The zip entry name to open a reader for. Specify null to access the first entry |
| zip | The ZipFile instance to be returned to the caller |
Definition at line 629 of file Compression.cs.
|
static |
Streams the unzipped file as key value pairs of file name to file contents. NOTE: When the returned enumerable finishes enumerating, the zip stream will be closed rendering all key value pair Value properties unaccessible. Ideally this would be enumerated depth first.
This method has the potential for a memory leak if each kvp.Value enumerable is not disposed
| filename | The zip file to stream |
Definition at line 680 of file Compression.cs.
|
static |
Lazily unzips the specified stream
| stream | The zipped stream to be read |
Definition at line 705 of file Compression.cs.
|
static |
Streams each line from the first zip entry in the specified zip file
| filename | The zip file path to stream |
Definition at line 721 of file Compression.cs.
|
static |
Unzip a local file and return its contents via streamreader:
Definition at line 772 of file Compression.cs.
|
static |
Unzip a stream that represents a zip file and return the first entry as a stream
Definition at line 806 of file Compression.cs.
|
static |
Unzip the given byte array and return the created file names.
| zipData | A byte array containing the zip |
| outputFolder | The target output folder |
Definition at line 847 of file Compression.cs.
|
static |
Unzip a local file and return the created file names
| zipFile | Location of the zip on the HD |
Definition at line 858 of file Compression.cs.
|
static |
Extracts all file from a zip archive and copies them to a destination folder.
| source | The source zip file. |
| destination | The destination folder to extract the file to. |
Definition at line 934 of file Compression.cs.
|
static |
Extract tar.gz files to disk
| source | Tar.gz source file |
| destination | Location folder to unzip to |
Definition at line 948 of file Compression.cs.
|
static |
Enumerate through the files of a TAR and get a list of KVP names-byte arrays
| stream | The input tar stream |
| isTarGz | True if the input stream is a .tar.gz or .tgz |
Definition at line 965 of file Compression.cs.
|
static |
Enumerate through the files of a TAR and get a list of KVP names-byte arrays.
| source |
Definition at line 988 of file Compression.cs.
|
static |
Validates whether the zip is corrupted or not
| path | Path to the zip file |
Definition at line 1023 of file Compression.cs.
|
static |
Returns the entry file names contained in a zip file
| zipFileName | The zip file name |
Definition at line 1036 of file Compression.cs.
|
static |
Return the entry file names contained in a zip file
| zipFileStream | Stream to the file |
Definition at line 1049 of file Compression.cs.
|
static |
Extracts a 7-zip archive to disk, using the 7-zip CLI utility
| inputFile | Path to the 7z file |
| outputDirectory | Directory to output contents of 7z |
| execTimeout | Timeout in seconds for how long we should wait for the extraction to complete |
| Exception | The extraction failed because of a timeout or the exit code was not 0 |
Definition at line 1064 of file Compression.cs.