private void btnUnpack_Click(object sender, EventArgs e) { string tempDir = Path.Combine(PluginPaths.GetPluginTempDirectory(Pointer), "TempUnpack"); if (Directory.Exists(tempDir)) { Directory.Delete(tempDir, true); } Directory.CreateDirectory(tempDir); rtbInputInfo.Text = ""; try { rtbInputInfo.Text += "Unpacking: "; PluginPacker.Unpack(tbInputDir.Text, tempDir); rtbInputInfo.Text += "SUCCESS\nReading Data Format: "; unpackedInputPath = tempDir; inputPtr = PackageDataManager.LoadData(tempDir); rtbInputInfo.Text += "SUCCESS"; panelPack.Enabled = true; } catch (Exception exception) { Directory.Delete(tempDir, true); rtbInputInfo.Text += "FAILED\n"; } }
private void btnUnpack_Click(object sender, EventArgs e) { string[] files = File.ReadAllLines(tbInputDir.Text); unpackedInputPath = new string[files.Length]; inputPtr = new BasePluginPointer[files.Length]; rtbInputInfo.Text = ""; for (int i = 0; i < files.Length; i++) { string tempDir = Path.Combine(PluginPaths.GetPluginTempDirectory(Pointer), "TempUnpack"); if (Directory.Exists(tempDir)) { Directory.Delete(tempDir, true); } Directory.CreateDirectory(tempDir); try { rtbInputInfo.Text += $"Unpacking({Path.GetFileName(files[i])}): "; PluginPacker.Unpack(files[i], tempDir); rtbInputInfo.Text += "SUCCESS\nReading Data Format: "; inputPtr[i] = PackageDataManager.LoadData(tempDir); string outPath = Path.Combine(PluginPaths.GetPluginTempDirectory(Pointer), inputPtr[i].PluginName); if (Directory.Exists(outPath)) { Directory.Delete(outPath, true); } Directory.Move(tempDir, outPath); unpackedInputPath[i] = outPath; rtbInputInfo.Text += "SUCCESS\n\n"; panelPack.Enabled = true; } catch (Exception exception) { Directory.Delete(tempDir, true); rtbInputInfo.Text += "FAILED\n" + exception.Message + "\n\n"; } } }
/// <summary> /// To String Implementation Listing all Retrievable Information about the Plugin. /// </summary> /// <returns>Information Text about this Object.</returns> public override string ToString() { StringBuilder builder = new StringBuilder(); builder.AppendLine("General:"); builder.AppendLine("\tIs Initialized: " + PluginManager.IsInitialized); builder.AppendLine("\tSystem Config Path: " + PluginPaths.InternalSystemConfigPath); builder.AppendLine("\tPlugin Dir: " + PluginPaths.PluginDirectory); builder.AppendLine("\tInstalled Packages Path: " + PluginPaths.PluginListFile); builder.AppendLine("\tGlobal Packages Path: " + PluginPaths.GlobalPluginListFile); builder.AppendLine(); builder.AppendLine(); builder.AppendLine("Plugin:"); builder.AppendLine("Name: " + PluginName); builder.AppendLine("\tFile: " + PluginName); builder.AppendLine("\tPlugin Directory: " + PluginPaths.GetPluginDirectory(PluginName)); builder.AppendLine("\tPlugin Config Directory: " + PluginPaths.GetPluginConfigDirectory(PluginName)); builder.AppendLine("\tPlugin Assembly Directory: " + PluginPaths.GetPluginAssemblyDirectory(PluginName)); builder.AppendLine("\tPlugin Temp Directory: " + PluginPaths.GetPluginTempDirectory(PluginName)); //builder.AppendLine($"\tPlugin Archive Backup: " + PluginPaths.GetPluginArchiveBackup(PluginName)); //builder.AppendLine($"\t\tPlugin Archive Backup Exists: " + File.Exists(PluginPaths.GetPluginArchiveBackup(PluginName))); builder.AppendLine("\tPlugin Assembly File: " + PluginPaths.GetPluginAssemblyFile(PluginName, PluginFile)); builder.AppendLine( "\t\tPlugin Assembly File Exists: " + File.Exists(PluginPaths.GetPluginAssemblyFile(PluginName, PluginFile)) ); //builder.AppendLine($"\tPlugin Version File: " + PluginPaths.GetPluginVersionFile(PluginName)); //builder.AppendLine($"\t\tPlugin Version File Exists: " + File.Exists(PluginPaths.GetPluginVersionFile(PluginName))); //builder.AppendLine($"\t\tPlugin Version File Key: " + PluginPaths.GetPluginVersion(PluginName)); //builder.AppendLine($"\t\tPlugin Version File Value: " + PluginPaths.GetPluginOriginURL(PluginName)); return(builder.ToString()); }
public void CheckAndUpdate( BasePluginPointer ptr, Func <string, string, bool> updateDialog, Action <string, int, int> setStatus) { setStatus?.Invoke($"[{ptr.PluginName}] Searching Updates.", 0, 1); BasePluginPointer originPtr = GetPointer(ptr.PluginOrigin); if (ptr.PluginVersion >= originPtr.PluginVersion) { setStatus?.Invoke($"[{ptr.PluginName}] Up to date.", 1, 1); return; } setStatus?.Invoke($"[{ptr.PluginName}] Waiting for User Input", 1, 3); if (updateDialog( $"Do you want to update {ptr.PluginName} : {ptr.PluginVersion} to {originPtr.PluginName} : {originPtr.PluginVersion}?", $"Update: {originPtr.PluginVersion}" )) { string tempFile = Path.Combine( PluginPaths.GetPluginTempDirectory(ptr), $"{originPtr.PluginName}_{originPtr.PluginVersion}_.zip" ); setStatus?.Invoke($"[{ptr.PluginName}] Installing Update", 1, 3); DownloadFile(originPtr, tempFile); PluginManager.AddPackage(tempFile, out string name); File.Delete(tempFile); } else { setStatus?.Invoke($"[{ptr.PluginName}] User denied update request.", 1, 3); } }