Пример #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.");
        }
Пример #2
0
        private void createPackageBtn_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(createSrcPath.Text) || String.IsNullOrEmpty(createPackagePath.Text))
            {
                MessageBox.Show("Please specify both Package and Destination paths first!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                createPackageBtn.Enabled = false;
                _displayTimer            = null;

                try
                {
                    var options = new PackageCreationOptions();
                    switch (packageVersion.SelectedIndex)
                    {
                    case 0:
                    case 1:
                    {
                        options.Version = PackageVersion.V13;
                        break;
                    }

                    case 2:
                    {
                        options.Version = PackageVersion.V10;
                        break;
                    }

                    case 3:
                    {
                        options.Version = PackageVersion.V9;
                        break;
                    }

                    case 4:
                    {
                        options.Version = PackageVersion.V7;
                        break;
                    }
                    }

                    switch (compressionMethod.SelectedIndex)
                    {
                    case 1:
                    {
                        options.Compression = CompressionMethod.Zlib;
                        break;
                    }

                    case 2:
                    {
                        options.Compression     = CompressionMethod.Zlib;
                        options.FastCompression = false;
                        break;
                    }

                    case 3:
                    {
                        options.Compression = CompressionMethod.LZ4;
                        break;
                    }

                    case 4:
                    {
                        options.Compression     = CompressionMethod.LZ4;
                        options.FastCompression = false;
                        break;
                    }
                    }

                    // Fallback to Zlib, if the package version doesn't support LZ4
                    if (options.Compression == CompressionMethod.LZ4 && options.Version <= PackageVersion.V9)
                    {
                        options.Compression = CompressionMethod.Zlib;
                    }

                    if (solid.Checked)
                    {
                        options.Flags |= PackageFlags.Solid;
                    }

                    if (allowMemoryMapping.Checked)
                    {
                        options.Flags |= PackageFlags.AllowMemoryMapping;
                    }

                    if (preloadIntoCache.Checked)
                    {
                        options.Flags |= PackageFlags.Preload;
                    }

                    options.Priority = (byte)packagePriority.Value;

                    var packager = new Packager();
                    packager.ProgressUpdate += PackageProgressUpdate;
                    packager.CreatePackage(createPackagePath.Text, createSrcPath.Text, options);

                    MessageBox.Show("Package created successfully.");
                }
                catch (Exception exc)
                {
                    MessageBox.Show($"Internal error!{Environment.NewLine}{Environment.NewLine}{exc}", "Package Build Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                finally
                {
                    packageProgressLabel.Text = "";
                    packageProgress.Value     = 0;
                    createPackageBtn.Enabled  = true;
                }
            }
        }