/// <summary> /// Writes the data from the stream. Read by "ReadFrom". /// </summary> public Godot.Error TryWriteTo(string filepath) { Godot.Error progress = Godot.Error.Ok; try { using (FileStream stream = File.Open(filepath, FileMode.OpenOrCreate)) { using (BinaryWriter writer = new BinaryWriter(stream)) { WriteTo(writer); } } } catch (System.UnauthorizedAccessException) { progress = Godot.Error.FileNoPermission; } return(progress); }
public static bool MakeApiAssembly(ApiAssemblyType apiType, string config) { string apiName = apiType == ApiAssemblyType.Core ? ApiAssemblyNames.Core : ApiAssemblyNames.Editor; string editorPrebuiltApiDir = Path.Combine(GodotSharpDirs.DataEditorPrebuiltApiDir, config); string resAssembliesDir = Path.Combine(GodotSharpDirs.ResAssembliesBaseDir, config); if (File.Exists(Path.Combine(editorPrebuiltApiDir, $"{apiName}.dll"))) { using (var copyProgress = new EditorProgress("mono_copy_prebuilt_api_assembly", $"Copying prebuilt {apiName} assembly...", 1)) { copyProgress.Step($"Copying {apiName} assembly", 0); return(CopyApiAssembly(editorPrebuiltApiDir, resAssembliesDir, apiName, apiType)); } } const string apiSolutionName = ApiAssemblyNames.SolutionName; using (var pr = new EditorProgress($"mono_build_release_{apiSolutionName}", $"Building {apiSolutionName} solution...", 3)) { pr.Step($"Generating {apiSolutionName} solution", 0); string apiSlnDir = Path.Combine(GodotSharpDirs.MonoSolutionsDir, _ApiFolderName(ApiAssemblyType.Core)); string apiSlnFile = Path.Combine(apiSlnDir, $"{apiSolutionName}.sln"); if (!Directory.Exists(apiSlnDir) || !File.Exists(apiSlnFile)) { var bindingsGenerator = new BindingsGenerator(); if (!Godot.OS.IsStdoutVerbose()) { bindingsGenerator.LogPrintEnabled = false; } Error err = bindingsGenerator.GenerateCsApi(apiSlnDir); if (err != Error.Ok) { ShowBuildErrorDialog($"Failed to generate {apiSolutionName} solution. Error: {err}"); return(false); } } pr.Step($"Building {apiSolutionName} solution", 1); if (!BuildApiSolution(apiSlnDir, config)) { return(false); } pr.Step($"Copying {apiName} assembly", 2); // Copy the built assembly to the assemblies directory string apiAssemblyDir = Path.Combine(apiSlnDir, apiName, "bin", config); if (!CopyApiAssembly(apiAssemblyDir, resAssembliesDir, apiName, apiType)) { return(false); } } return(true); }