Hey Guys,
I’m trying to read the contents of a .GZ file in max by using the dotnet GZIPStream class. Now I am a little inexperienced when it comes to .NET so I am currently looking at this example for extracting a set of files provided with the class description and I am trying to put that into proper MXS:
public static void Decompress(FileInfo fileToDecompress)
{
using (FileStream originalFileStream = fileToDecompress.OpenRead())
{
string currentFileName = fileToDecompress.FullName;
string newFileName = currentFileName.Remove(currentFileName.Length - fileToDecompress.Extension.Length);
using (FileStream decompressedFileStream = File.Create(newFileName))
{
using (GZipStream decompressionStream = new GZipStream(originalFileStream, CompressionMode.Decompress))
{
decompressionStream.CopyTo(decompressedFileStream);
Console.WriteLine($"Decompressed: {fileToDecompress.Name}");
}
}
}
}
I know how to use dotnet classes and objects, but I cannot wrap my head around the bits where the GZIPStream class is being used in the following way and how to translate that to MXS:
using (GZipStream decompressionStream = new GZipStream(originalFileStream, CompressionMode.Decompress))
What I have so far is this;
fn decompress fileName newFileName= (
currentFileName = fileName
newFileName = newFileName
decompressedFileStream = undefined
(dotnetClass "System.IO.FileStream") decompressedFileStream = ((dotnetClass "System.IO.File").create fileName)
decompressionStream = dotnetClass "System.IO.Compression.GZIPStream" decompressedFileStream (dotnetClass "System.IO.Compression)"CompressionMode.Decompress
)
obviously that doesn’t work and isn’t finished but can anybody point me in the right direction?