private static IEnumerable <CustomFolderPath> Get3DSPaths() { var path3DS = PathUtilWindows.GetSwitchLocation(); if (path3DS == null || !Directory.Exists(path3DS)) { return(Enumerable.Empty <CustomFolderPath>()); } var root = Path.GetPathRoot(path3DS); var paths = PathUtilWindows.GetSwitchBackupPaths(root); return(paths.Select(z => new CustomFolderPath(z))); }
private static IEnumerable <CustomFolderPath> Get3DSPaths() { var path3DS = PathUtilWindows.Get3DSLocation(); var path = path3DS == null || !Directory.Exists(path3DS) ? @"C:\" : Path.GetPathRoot(path3DS); foreach (var z in PathUtilWindows.Get3DSBackupPaths(path)) { var di = new DirectoryInfo(z); var root = di.Root.Name; var folder = di.Parent.Name; if (root == folder) { folder = di.Name; } yield return(new CustomFolderPath { Path = z, DisplayText = folder }); } }
/// <summary> /// Opens a dialog to open a <see cref="SaveFile"/>, <see cref="PKM"/> file, or any other supported file. /// </summary> /// <param name="Extensions">Misc extensions of <see cref="PKM"/> files supported by the SAV.</param> /// <param name="path">Output result path</param> /// <returns>Result of whether or not a file is to be loaded from the output path.</returns> public static bool OpenSAVPKMDialog(IEnumerable <string> Extensions, out string path) { string supported = string.Join(";", Extensions.Select(s => $"*.{s}").Concat(new[] { "*.pkm" })); OpenFileDialog ofd = new OpenFileDialog { Filter = "All Files|*.*" + $"|Supported Files|main;*.sav;*.dat;*.gci;*.bin;{supported};*.bak" + "|3DS Main Files|main" + "|Save Files|*.sav;*.dat;*.gci" + "|Decrypted PKM File|" + supported + "|Binary File|*.bin" + "|Backup File|*.bak" }; // Detect main string cgse = ""; string pathCache = CyberGadgetUtil.GetCacheFolder(); if (Directory.Exists(pathCache)) { cgse = Path.Combine(pathCache); } if (!PathUtilWindows.DetectSaveFile(out path, cgse) && !string.IsNullOrEmpty(path)) { Error(path); // `path` contains the error message path = null; } if (path != null) { ofd.FileName = path; } if (ofd.ShowDialog() != DialogResult.OK) { return(false); } path = ofd.FileName; return(true); }