Beispiel #1
0
        private static void CreatePackageResource(string file = "")
        {
            if (string.IsNullOrEmpty(file))
            {
                file = CommandLineActions.DestinationPath;
                CommandLineLogger.LogDebug($"Using destination path: {file}");
            }

            var options = new PackageCreationOptions();

            options.Version = CommandLineActions.PackageVersion;

            Dictionary <string, object> compressionOptions = CommandLineArguments.GetCompressionOptions(Path.GetExtension(file)?.ToLower() == ".lsv" ? "zlib" : Args.CompressionMethod, options.Version);

            options.Compression     = (CompressionMethod)compressionOptions["Compression"];
            options.FastCompression = (bool)compressionOptions["FastCompression"];

            var fast = options.FastCompression ? "Fast" : "Normal";

            CommandLineLogger.LogDebug($"Using compression method: {options.Compression.ToString()} ({fast})");

            var packager = new Packager();

            packager.CreatePackage(file, CommandLineActions.SourcePath, options);

            CommandLineLogger.LogInfo("Package created successfully.");
        }
Beispiel #2
0
        private static void ExtractPackageResource(string file = "", string folder = "")
        {
            if (string.IsNullOrEmpty(file))
            {
                file = CommandLineActions.SourcePath;
                CommandLineLogger.LogDebug($"Using source path: {file}");
            }

            try
            {
                Packager packager = new Packager();

                string extractionPath = GetExtractionPath(folder, CommandLineActions.DestinationPath);

                CommandLineLogger.LogDebug($"Using extraction path: {extractionPath}");

                packager.UncompressPackage(file, extractionPath);

                CommandLineLogger.LogInfo($"Extracted package to: {extractionPath}");
            }
            catch (NotAPackageException)
            {
                CommandLineLogger.LogFatal("Failed to extract package because the package is not an Original Sin package or savegame archive", 1);
            }
            catch (Exception e)
            {
                CommandLineLogger.LogFatal($"Failed to extract package: {e.Message}", 2);
                CommandLineLogger.LogTrace($"{e.StackTrace}");
            }
        }
        private static void ConvertResource(string file)
        {
            var exporter = new Exporter
            {
                Options = UpdateExporterSettings()
            };

            if (!string.IsNullOrEmpty(file))
            {
                exporter.Options.InputPath = file;
            }

#if !DEBUG
            try
            {
#endif
            exporter.Export();

            CommandLineLogger.LogInfo("Export completed successfully.");
#if !DEBUG
        }
        catch (Exception e)
        {
            CommandLineLogger.LogFatal($"Export failed: {e.Message + Environment.NewLine + e.StackTrace}", 2);
        }
#endif
        }
Beispiel #4
0
        public static void BatchExtract(Func <AbstractFileInfo, bool> filter = null)
        {
            string[] files = Directory.GetFiles(CommandLineActions.SourcePath, $"*.{Args.InputFormat}");

            foreach (string file in files)
            {
                string extractionPath = GetExtractionPath(file, CommandLineActions.DestinationPath);

                CommandLineLogger.LogInfo($"Extracting package: {file}");

                ExtractPackageResource(file, extractionPath, filter);
            }
        }
Beispiel #5
0
        public static void Extract(Func <AbstractFileInfo, bool> filter = null)
        {
            if (CommandLineActions.SourcePath == null)
            {
                CommandLineLogger.LogFatal("Cannot extract package without source path", 1);
            }
            else
            {
                string extractionPath = GetExtractionPath(CommandLineActions.SourcePath, CommandLineActions.DestinationPath);

                CommandLineLogger.LogInfo($"Extracting package: {CommandLineActions.SourcePath}");

                ExtractPackageResource(CommandLineActions.SourcePath, extractionPath, filter);
            }
        }
Beispiel #6
0
        private static void BatchConvertResource(string sourcePath, string destinationPath, ResourceFormat inputFormat, ResourceFormat outputFormat, FileVersion fileVersion)
        {
            try
            {
                CommandLineLogger.LogDebug($"Using destination extension: {outputFormat}");

                ResourceUtils resourceUtils = new ResourceUtils();
                resourceUtils.ConvertResources(sourcePath, destinationPath, inputFormat, outputFormat, fileVersion);

                CommandLineLogger.LogInfo($"Wrote resources to: {destinationPath}");
            }
            catch (Exception e)
            {
                CommandLineLogger.LogFatal($"Failed to batch convert resources: {e.Message}", 2);
                CommandLineLogger.LogTrace($"{e.StackTrace}");
            }
        }
Beispiel #7
0
        private static void ConvertResource(string sourcePath, string destinationPath, FileVersion fileVersion)
        {
            try
            {
                ResourceFormat resourceFormat = ResourceUtils.ExtensionToResourceFormat(destinationPath);
                CommandLineLogger.LogDebug($"Using destination extension: {resourceFormat}");

                Resource resource = ResourceUtils.LoadResource(sourcePath);

                ResourceUtils.SaveResource(resource, destinationPath, resourceFormat, fileVersion);

                CommandLineLogger.LogInfo($"Wrote resource to: {destinationPath}");
            }
            catch (Exception e)
            {
                CommandLineLogger.LogFatal($"Failed to convert resource: {e.Message}", 2);
                CommandLineLogger.LogTrace($"{e.StackTrace}");
            }
        }
Beispiel #8
0
        private static void CreatePackageResource(string file = "")
        {
            if (string.IsNullOrEmpty(file))
            {
                file = CommandLineActions.DestinationPath;
                CommandLineLogger.LogDebug($"Using destination path: {file}");
            }

            PackageVersion packageVersion = CommandLineActions.PackageVersion;
            Dictionary <string, object> compressionOptions = CommandLineArguments.GetCompressionOptions(Path.GetExtension(file)?.ToLower() == ".lsv" ? "zlib" : Args.CompressionMethod, packageVersion);

            CompressionMethod compressionMethod = (CompressionMethod)compressionOptions["Compression"];
            bool compressionSpeed = (bool)compressionOptions["FastCompression"];

            CommandLineLogger.LogDebug($"Using compression method: {compressionMethod.ToString()}");
            CommandLineLogger.LogDebug($"Using fast compression: {compressionSpeed}");

            Packager packager = new Packager();

            packager.CreatePackage(file, CommandLineActions.SourcePath, packageVersion, compressionMethod, compressionSpeed);

            CommandLineLogger.LogInfo("Package created successfully.");
        }
        private static void ConvertResource(string file)
        {
            Exporter exporter = new Exporter
            {
                Options = UpdateExporterSettings()
            };

            if (!string.IsNullOrEmpty(file))
            {
                exporter.Options.InputPath = file;
            }

            try
            {
                exporter.Export();
                CommandLineLogger.LogInfo("Export completed successfully.");
            }
            catch (Exception e)
            {
                CommandLineLogger.LogFatal($"Export failed: {e.Message}", 2);
                CommandLineLogger.LogTrace($"{e.StackTrace}");
            }
        }