Beispiel #1
0
        public Dictionary <string, object> CreateDisk(string name, Dictionary <WorkspacePath, WorkspacePath> files, WorkspacePath dest, int maxFileSize = 512)
        {
            var fileLoader = new WorkspaceFileLoadHelper(workspace);

            dest = workspace.UniqueFilePath(dest.AppendDirectory("Build")).AppendPath(name + ".pv8");
            var diskExporter = new DiskExporter(dest.Path, fileLoader, files, maxFileSize);

            if (((DesktopRunner)runner).ExportService is GameDataExportService exportService)
            {
                exportService.Clear();

                exportService.AddExporter(diskExporter);

                exportService.StartExport();

                // Update the response
                diskExporter.Response["success"] = true;
                diskExporter.Response["message"] = "A new build was created in " + dest + ".";
                diskExporter.Response["path"]    = dest.Path;
            }
            else
            {
                diskExporter.Response["success"] = false;
                diskExporter.Response["message"] = "Couldn't find the service to save a disk.";
            }

            return(diskExporter.Response);
        }
Beispiel #2
0
        public Dictionary <string, object> CreateZipFile(WorkspacePath path, Dictionary <WorkspacePath, WorkspacePath> files)
        {
            var fileHelper  = new WorkspaceFileLoadHelper(this);
            var zipExporter = new ZipExporter(path.Path, fileHelper, files);

            zipExporter.CalculateSteps();

            while (zipExporter.completed == false)
            {
                zipExporter.NextStep();
            }

            try
            {
                if ((bool)zipExporter.Response["success"])
                {
                    var zipPath = WorkspacePath.Parse(zipExporter.fileName);

                    SaveExporterFiles(new Dictionary <string, byte[]>()
                    {
                        { zipExporter.fileName, zipExporter.bytes }
                    });
                }
            }
            catch (Exception e)
            {
                // Change the success to false
                zipExporter.Response["success"] = false;
                zipExporter.Response["message"] = e.Message;
            }


            return(zipExporter.Response);
        }