예제 #1
0
        private static string GetCorrectedPackagePath(UnzipPkgOptions options)
        {
            var packagePath = options.Name;

            if (!packagePath.EndsWith(".gz"))
            {
                packagePath += ".gz";
            }
            return(packagePath);
        }
예제 #2
0
        public static int ExtractPackage(UnzipPkgOptions options, IPackageArchiver packageArchiver,
                                         IPackageUtilities packageUtilities, IFileSystem fileSystem)
        {
            var    packagePath            = GetCorrectedPackagePath(options);
            var    destinationDirectory   = fileSystem.GetCurrentDirectoryIfEmpty(options.DestinationPath);
            string packageName            = fileSystem.ExtractNameFromPath(packagePath);
            var    destinationPackagePath = Path.Combine(destinationDirectory, packageName);

            try {
                Console.WriteLine($"Start unzip package ({packageName}).");
                var overwrite = ShowDialogOverwriteDestinationPackageDir(destinationPackagePath);
                packageArchiver.Unpack(packagePath, overwrite, destinationDirectory);
                Console.WriteLine($"Unzip package ({packageName}) completed.");
                return(0);
            } catch (Exception e) {
                Console.WriteLine($"{e.Message}");
                return(1);
            }
        }