/// <summary> /// Detects a save file. /// </summary> /// <returns>Full path of a save file. Returns null if unable to find any.</returns> public static bool detectSaveFile(out string path, params string[] extra) { string path3DS = Path.GetPathRoot(Util.get3DSLocation()); List <string> possiblePaths = new List <string>(); List <string> foldersToCheck = new List <string>(extra.Where(f => f?.Length > 0)); // Homebrew/CFW if (path3DS != null) { foldersToCheck.AddRange(new[] { Path.Combine(path3DS, "saveDataBackup"), Path.Combine(path3DS, "filer", "UserSaveData"), Path.Combine(path3DS, "JKSV", "Saves"), Path.Combine(path3DS, "TWLSaveTool"), Path.Combine(path3DS, "fbi", "save"), }); } foreach (var p in foldersToCheck) { IEnumerable <string> files; if (!getSavesFromFolder(p, true, out files)) { if (files == null) { continue; } path = files.First(); // error return(false); } possiblePaths.AddRange(files); } // return newest save file path that is valid (oh man) path = possiblePaths.OrderByDescending(f => new FileInfo(f).LastWriteTime).FirstOrDefault(p => getVariantSAV(File.ReadAllBytes(p))?.ChecksumsValid ?? false); return(true); }