Exemple #1
0
        public static bool ExtractToDirectory(string fileNamePath, string outputDirectory)
        {
            // bsdtar has a bug and hangs, so we are doing it in two steps.
            if (Core.IsWindows)
            {
                var tempDir        = PathUtility.EnsureRandomPath(Path.GetTempPath());
                var tempTarArchive = Path.Combine(tempDir, "temp-file.tar");

                try
                {
                    var process = new Process
                    {
                        StartInfo = new ProcessStartInfo
                        {
                            FileName  = Path.Combine(_pathToZstd, "zstd.exe"),
                            Arguments = $"-q -d \"{fileNamePath}\" -o \"{tempTarArchive}\""
                        }
                    };

                    process.Start();
                    process.WaitForExit();

                    return(process.ExitCode == 0 && TarArchive.ExtractToDirectory(tempTarArchive, outputDirectory));
                }
                catch
                {
                    return(false);
                }
                finally
                {
                    File.Delete(tempTarArchive);
                }
            }

            return(TarArchive.ExtractToDirectory(fileNamePath, outputDirectory, "zstd -q -d", _pathToZstd));
        }