public GameImporterForm(List <FoundGame> games) : this() { foreach (var game in games.OrderBy(e => e.Desktop.Name)) { var item = new ListViewItem(); listViewGames.Items.Add(new ListViewItem(new ListViewItem.ListViewSubItem[] { new ListViewItem.ListViewSubItem() { Text = game.Desktop.Name }, new ListViewItem.ListViewSubItem() { Text = game.RemotePath }, new ListViewItem.ListViewSubItem() { Text = Shared.SizeSuffix(game.Size, 2) }, }, 0) { Tag = game }); } }
private void TechInfo_Load(object sender, EventArgs e) { try { ListViewGroup generalInfoGroup = new ListViewGroup("General information"), localHakchiGroup = new ListViewGroup("Loadl hakchi.hmod"), shellInfoGroup = new ListViewGroup("Shell information"), hakchiGroup = new ListViewGroup("Running hakchi.hmod info"), pathsGroup = new ListViewGroup("Paths"), memoryStatsGroup = new ListViewGroup("Memory stats"), consoleSettingsGroup = new ListViewGroup("Console settings"), settingsGroup = new ListViewGroup("Settings"); listView1.Groups.AddRange(new ListViewGroup[] { generalInfoGroup, localHakchiGroup, shellInfoGroup, hakchiGroup, pathsGroup, memoryStatsGroup, consoleSettingsGroup, settingsGroup }); string devTools = ""; if (ConfigIni.Instance.ForceClovershell) { devTools += "Force Clovershell, "; } if (ConfigIni.Instance.ForceSSHTransfers) { devTools += "Force SSH Transfers, "; } if (ConfigIni.Instance.UploadToTmp) { devTools += "Upload to /tmp, "; } devTools = devTools.TrimEnd(new char[] { ',', ' ' }); if (string.IsNullOrWhiteSpace(devTools)) { devTools = "None"; } var gamesSize = Shared.DirectorySize(Path.Combine(Program.BaseDirectoryExternal, "games")); var gamesNum = gamesSize > 0 ? Directory.EnumerateDirectories(Path.Combine(Program.BaseDirectoryExternal, "games")).Count() : 0; var gamesSnesSize = Shared.DirectorySize(Path.Combine(Program.BaseDirectoryExternal, "games_snes")); var gamesSnesNum = gamesSnesSize > 0 ? Directory.EnumerateDirectories(Path.Combine(Program.BaseDirectoryExternal, "games_snes")).Count() : 0; var gamesCacheSize = Shared.DirectorySize(Path.Combine(Program.BaseDirectoryExternal, "games_cache")); var gamesCacheNum = gamesCacheSize > 0 ? Directory.EnumerateDirectories(Path.Combine(Program.BaseDirectoryExternal, "games_cache")).Count() : 0; listView1.Items.AddRange(new ListViewItem[] { // general info new ListViewItem(new string[] { "hakchi2 CE version:", Shared.AppDisplayVersion }, generalInfoGroup), new ListViewItem(new string[] { "Portable mode:", Program.isPortable ? Resources.Yes : Resources.No }, generalInfoGroup), new ListViewItem(new string[] { "Developer tools:", devTools }, generalInfoGroup), new ListViewItem(new string[] { "Internal path:", Program.BaseDirectoryInternal }, generalInfoGroup), new ListViewItem(new string[] { "External path:", Program.BaseDirectoryExternal }, generalInfoGroup), new ListViewItem(new string[] { "/games:", gamesNum > 0 ? ($"{gamesNum} directories (" + Shared.SizeSuffix(gamesSize) + ")") : Resources.None }, generalInfoGroup), new ListViewItem(new string[] { "/games_snes:", gamesSnesNum > 0 ? ($"{gamesSnesNum} directories (" + Shared.SizeSuffix(gamesSnesSize) + ")") : Resources.None }, generalInfoGroup), new ListViewItem(new string[] { "/games_cache", gamesCacheNum > 0 ? ($"{gamesCacheNum} directories (" + Shared.SizeSuffix(gamesCacheSize) + ")") : Resources.None }, generalInfoGroup), // local hakchi info new ListViewItem(new string[] { "Boot version:", hakchi.RawLocalBootVersion }, localHakchiGroup), new ListViewItem(new string[] { "Kernel version:", hakchi.RawLocalKernelVersion }, localHakchiGroup), new ListViewItem(new string[] { "Script version:", hakchi.RawLocalScriptVersion }, localHakchiGroup), // shell info new ListViewItem(new string[] { "Connected:", hakchi.Connected ? Resources.Yes : Resources.No }, shellInfoGroup), // settings new ListViewItem(new string[] { "Separate games for multiboot:", ConfigIni.Instance.SeparateGameStorage ? Resources.Yes : Resources.No }, settingsGroup), new ListViewItem(new string[] { "Use linked sync:", ConfigIni.Instance.SyncLinked ? Resources.Yes : Resources.No }, settingsGroup), }); if (hakchi.Connected) { // shell string shell = Resources.Unknown; if (hakchi.Shell is INetworkShell) { shell = "SSH"; } else if (hakchi.Shell is clovershell.ClovershellConnection) { shell = "Clovershell"; } listView1.Items.AddRange(new ListViewItem[] { // shell info new ListViewItem(new string[] { "Shell:", shell }, shellInfoGroup), new ListViewItem(new string[] { "Can interact:", hakchi.CanInteract ? Resources.Yes : Resources.No }, shellInfoGroup), new ListViewItem(new string[] { "Minimal memboot:", hakchi.MinimalMemboot ? Resources.Yes : Resources.No }, shellInfoGroup), new ListViewItem(new string[] { "Console unique ID:", hakchi.UniqueID }, shellInfoGroup), // hakchi info new ListViewItem(new string[] { "Boot version:", hakchi.RawBootVersion }, hakchiGroup), new ListViewItem(new string[] { "Kernel version:", hakchi.RawKernelVersion }, hakchiGroup), new ListViewItem(new string[] { "Script version:", hakchi.RawScriptVersion }, hakchiGroup), }); if (hakchi.MinimalMemboot) { // no-op } else { if (hakchi.CanInteract) { listView1.Items.AddRange(new ListViewItem[] { // more shell info new ListViewItem(new string[] { "Detected console type:", MainForm.GetConsoleTypeName(hakchi.DetectedConsoleType) }, shellInfoGroup), new ListViewItem(new string[] { "Custom firmware:", hakchi.CustomFirmwareLoaded ? Resources.Yes : Resources.No }, shellInfoGroup), // paths new ListViewItem(new string[] { "Config:", hakchi.ConfigPath }, pathsGroup), new ListViewItem(new string[] { "Remote sync:", hakchi.RemoteGameSyncPath }, pathsGroup), new ListViewItem(new string[] { "System code:", hakchi.SystemCode ?? "-" }, pathsGroup), new ListViewItem(new string[] { "Media:", hakchi.MediaPath }, pathsGroup), new ListViewItem(new string[] { "Original games:", hakchi.OriginalGamesPath }, pathsGroup), new ListViewItem(new string[] { "Games:", hakchi.GamesPath }, pathsGroup), new ListViewItem(new string[] { "RootFS:", hakchi.RootFsPath }, pathsGroup), new ListViewItem(new string[] { "Profile:", hakchi.GamesProfilePath }, pathsGroup), new ListViewItem(new string[] { "SquashFS:", hakchi.SquashFsPath }, pathsGroup), // memory stats new ListViewItem(new string[] { "Storage total:", Shared.SizeSuffix(MemoryStats.StorageTotal) }, memoryStatsGroup), new ListViewItem(new string[] { "Storage used:", Shared.SizeSuffix(MemoryStats.StorageUsed) }, memoryStatsGroup), new ListViewItem(new string[] { "Storage free:", Shared.SizeSuffix(MemoryStats.StorageFree) }, memoryStatsGroup), new ListViewItem(new string[] { "External saves:", MemoryStats.ExternalSaves ? Resources.Yes : Resources.No }, memoryStatsGroup), new ListViewItem(new string[] { "Saves:", Shared.SizeSuffix(MemoryStats.SaveStatesSize) }, memoryStatsGroup), new ListViewItem(new string[] { "All games:", Shared.SizeSuffix(MemoryStats.AllGamesSize) }, memoryStatsGroup), new ListViewItem(new string[] { "Non multiboot games:", Shared.SizeSuffix(MemoryStats.NonMultibootGamesSize) }, memoryStatsGroup), new ListViewItem(new string[] { "Extra files:", Shared.SizeSuffix(MemoryStats.ExtraFilesSize) }, memoryStatsGroup), }); // collections sizes foreach (var pair in MemoryStats.Collections) { listView1.Items.Add( new ListViewItem(new string[] { MainForm.GetConsoleTypeName(pair.Key) + " games:", Shared.SizeSuffix(pair.Value) }, memoryStatsGroup)); } } } } logContentsRichTextBox.Text = Program.GetCurrentLogContent(); } catch (Exception ex) { Tasks.ErrorForm.Show(this, ex); } }
private void TechInfo_Load(object sender, EventArgs e) { string devTools = ""; if (ConfigIni.Instance.ForceClovershell) { devTools += "Force Clovershell, "; } if (ConfigIni.Instance.ForceSSHTransfers) { devTools += "Force SSH Transfers, "; } if (ConfigIni.Instance.UploadToTmp) { devTools += "Upload to /tmp, "; } if (ConfigIni.Instance.DisableClovershellListener) { devTools += "Disable Clovershell listener, "; } if (ConfigIni.Instance.DisableSSHListener) { devTools += "Disable SSH listener, "; } devTools = devTools.TrimEnd(new char[] { ',', ' ' }); if (string.IsNullOrWhiteSpace(devTools)) { devTools = "None"; } var gamesSize = Shared.DirectorySize(Path.Combine(Program.BaseDirectoryExternal, "games")); var gamesNum = Directory.EnumerateDirectories(Path.Combine(Program.BaseDirectoryExternal, "games")).Count(); var gamesSnesSize = Shared.DirectorySize(Path.Combine(Program.BaseDirectoryExternal, "games_snes")); var gamesSnesNum = Directory.EnumerateDirectories(Path.Combine(Program.BaseDirectoryExternal, "games_snes")).Count(); var gamesCacheSize = Shared.DirectorySize(Path.Combine(Program.BaseDirectoryExternal, "games_cache")); var gamesCacheNum = Directory.EnumerateDirectories(Path.Combine(Program.BaseDirectoryExternal, "games_cache")).Count(); listView1.Items.AddRange(new ListViewItem[] { // general info new ListViewItem(new string[] { "hakchi2 CE version:", Shared.AppDisplayVersion }, listView1.Groups[0]), new ListViewItem(new string[] { "Portable mode:", Program.isPortable ? Resources.Yes : Resources.No }, listView1.Groups[0]), new ListViewItem(new string[] { "Developer tools:", devTools }, listView1.Groups[0]), new ListViewItem(new string[] { "Internal path:", Program.BaseDirectoryInternal }, listView1.Groups[0]), new ListViewItem(new string[] { "External path:", Program.BaseDirectoryExternal }, listView1.Groups[0]), new ListViewItem(new string[] { "/games:", $"{gamesNum} directories (" + Shared.SizeSuffix(gamesSize) + ")" }, listView1.Groups[0]), new ListViewItem(new string[] { "/games_snes:", $"{gamesSnesNum} directories (" + Shared.SizeSuffix(gamesSnesSize) + ")" }, listView1.Groups[0]), new ListViewItem(new string[] { "/games_cache", $"{gamesCacheNum} directories (" + Shared.SizeSuffix(gamesCacheSize) + ")" }, listView1.Groups[0]), // settings new ListViewItem(new string[] { "Separate games for multiboot:", ConfigIni.Instance.SeparateGameStorage ? Resources.Yes : Resources.No }, listView1.Groups[6]), new ListViewItem(new string[] { "Use linked sync:", ConfigIni.Instance.SyncLinked ? Resources.Yes : Resources.No }, listView1.Groups[6]), }); string shell = Resources.Unknown; string connected = Resources.No; string minimalMemboot = Resources.No; if (hakchi.Connected) { // shell connected = Resources.Yes; if (hakchi.Shell is INetworkShell) { shell = "SSH"; } else if (hakchi.Shell is clovershell.ClovershellConnection) { shell = "Clovershell"; } // shell info listView1.Items.AddRange(new ListViewItem[] { new ListViewItem(new string[] { "Connected:", connected }, listView1.Groups[1]), new ListViewItem(new string[] { "Shell:", shell }, listView1.Groups[1]), new ListViewItem(new string[] { "Can interact:", hakchi.CanInteract ? Resources.Yes : Resources.No }, listView1.Groups[1]), new ListViewItem(new string[] { "Minimal memboot:", hakchi.MinimalMemboot ? Resources.Yes : Resources.No }, listView1.Groups[1]), }); if (hakchi.MinimalMemboot) { // no-op } if (hakchi.CanInteract) { listView1.Items.AddRange(new ListViewItem[] { // more shell info new ListViewItem(new string[] { "Detected console type:", MainForm.GetConsoleTypeName(hakchi.DetectedConsoleType) }, listView1.Groups[1]), new ListViewItem(new string[] { "Custom firmware:", hakchi.CustomFirmwareLoaded ? Resources.Yes : Resources.No }, listView1.Groups[1]), new ListViewItem(new string[] { "Console unique ID:", hakchi.UniqueID }, listView1.Groups[1]), // hakchi info new ListViewItem(new string[] { "Boot version:", hakchi.BootVersion }, listView1.Groups[2]), new ListViewItem(new string[] { "Kernel version:", hakchi.KernelVersion }, listView1.Groups[2]), new ListViewItem(new string[] { "Script version:", hakchi.ScriptVersion }, listView1.Groups[2]), // paths new ListViewItem(new string[] { "Config:", hakchi.ConfigPath }, listView1.Groups[3]), new ListViewItem(new string[] { "Remote sync:", hakchi.RemoteGameSyncPath }, listView1.Groups[3]), new ListViewItem(new string[] { "System code:", hakchi.SystemCode ?? "-" }, listView1.Groups[3]), new ListViewItem(new string[] { "Media:", hakchi.MediaPath }, listView1.Groups[3]), new ListViewItem(new string[] { "Original games:", hakchi.OriginalGamesPath }, listView1.Groups[3]), new ListViewItem(new string[] { "Games:", hakchi.GamesPath }, listView1.Groups[3]), new ListViewItem(new string[] { "RootFS:", hakchi.RootFsPath }, listView1.Groups[3]), new ListViewItem(new string[] { "Profile:", hakchi.GamesProfilePath }, listView1.Groups[3]), new ListViewItem(new string[] { "SquashFS:", hakchi.SquashFsPath }, listView1.Groups[3]), // memory stats new ListViewItem(new string[] { "Storage total:", Shared.SizeSuffix(MemoryStats.StorageTotal) }, listView1.Groups[4]), new ListViewItem(new string[] { "Storage used:", Shared.SizeSuffix(MemoryStats.StorageUsed) }, listView1.Groups[4]), new ListViewItem(new string[] { "Storage free:", Shared.SizeSuffix(MemoryStats.StorageFree) }, listView1.Groups[4]), new ListViewItem(new string[] { "External saves:", MemoryStats.ExternalSaves ? Resources.Yes : Resources.No }, listView1.Groups[4]), new ListViewItem(new string[] { "Saves:", Shared.SizeSuffix(MemoryStats.SaveStatesSize) }, listView1.Groups[4]), new ListViewItem(new string[] { "All games:", Shared.SizeSuffix(MemoryStats.AllGamesSize) }, listView1.Groups[4]), new ListViewItem(new string[] { "Non multiboot games:", Shared.SizeSuffix(MemoryStats.NonMultibootGamesSize) }, listView1.Groups[4]), new ListViewItem(new string[] { "Extra files:", Shared.SizeSuffix(MemoryStats.ExtraFilesSize) }, listView1.Groups[4]), // console settings new ListViewItem(new string[] { "USB host enabled", ConfigIni.Instance.UsbHost ? Resources.Yes : Resources.No }, listView1.Groups[5]), new ListViewItem(new string[] { "Fontfix enabled", ConfigIni.Instance.UseFont ? Resources.Yes : Resources.No }, listView1.Groups[5]), }); // collections sizes foreach (var pair in MemoryStats.Collections) { listView1.Items.Add( new ListViewItem(new string[] { MainForm.GetConsoleTypeName(pair.Key) + " games:", Shared.SizeSuffix(pair.Value) }, listView1.Groups[4])); } } } else { listView1.Items.AddRange(new ListViewItem[] { new ListViewItem(new string[] { "Connected:", connected }, listView1.Groups[1]), }); } }
public static TaskFunc GameCopyTask(FoundGame game) { return((Tasker tasker, Object sync) => { if (game.Desktop.Code.StartsWith("CLV-")) { long dataTransferred = 0; var destinationPath = Path.Combine(NesApplication.GamesDirectory, game.Desktop.Code); tasker?.SetStatus($"{game.Desktop.Name}"); if (Directory.Exists(destinationPath)) { Directory.Delete(destinationPath, true); } Directory.CreateDirectory(destinationPath); foreach (var folder in hakchi.Shell.ExecuteSimple($"cd {Shared.EscapeShellArgument(game.RemotePath)}; find -type d").Split('\n')) { Directory.CreateDirectory(Path.Combine(destinationPath, folder)); } FtpClient ftp = null; if (hakchi.Shell is INetworkShell) { ftp = new FtpClient(new Uri($"ftp://{(hakchi.Shell as INetworkShell).IPAddress}"), new NetworkCredential("root", "root")); } foreach (Match match in new Regex(@"^(\d+)\s*\./(.*)$", RegexOptions.Multiline).Matches(hakchi.Shell.ExecuteSimple($"cd {Shared.EscapeShellArgument(game.RemotePath)}; find -type f -exec du {"{}"} \\;"))) { var size = long.Parse(match.Groups[1].Value) * 1024; var filename = match.Groups[2].Value; using (var file = File.Create(Path.Combine(destinationPath, filename))) using (var tracker = new TrackableStream(file)) { tracker.OnProgress += (long transferred, long length) => { var totalTransferred = Math.Min(dataTransferred + transferred, game.Size); tasker?.SetProgress(totalTransferred, game.Size); tasker?.SetStatus($"{game.Desktop.Name} ({Shared.SizeSuffix(totalTransferred, 2)} / {Shared.SizeSuffix(game.Size, 2)})"); }; if (hakchi.Shell is INetworkShell) { using (var ftpStream = ftp.Retr($"{game.RemotePath}/{filename}")) { ftpStream.CopyTo(tracker); } } else { hakchi.Shell.Execute($"cat {Shared.EscapeShellArgument($"{game.RemotePath}/{filename}")}", null, tracker, throwOnNonZero: true); } dataTransferred += size; } } ftp?.Dispose(); ftp = null; game.Desktop.Save(Path.Combine(destinationPath, $"{game.Desktop.Code}.desktop")); if (!ConfigIni.Instance.SelectedGames.Contains(game.Desktop.Code)) { ConfigIni.Instance.SelectedGames.Add(game.Desktop.Code); } return Conclusion.Success; } return Conclusion.Error; }); }
private void listViewGames_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e) { var totalSize = SelectedGames .Select(game => game.Size) .Sum(); if (listViewGames.SelectedItems.Count == 0) { labelStatus.Text = NoSelection; } else { labelStatus.Text = string.Format(listViewGames.SelectedItems.Count == 1 ? SingleSelection : MultiSelection, listViewGames.SelectedItems.Count, Shared.SizeSuffix(totalSize)); } buttonImport.Enabled = listViewGames.SelectedItems.Count > 0; }