Exemple #1
0
        /// <summary>
        /// Detects a save file.
        /// </summary>
        /// <returns>Full path of a save file. Returns null if unable to find any.</returns>
        public static string detectSaveFile()
        {
            string        path;
            string        path3DS       = Path.GetPathRoot(Util.get3DSLocation());
            List <string> possiblePaths = new List <string>();

            // save_manager
            if (path3DS != null && Directory.Exists(path = Path.Combine(path3DS, "saveDataBackup")))
            {
                possiblePaths.AddRange(getSavesFromFolder(path, false));
            }

            // SaveDataFiler
            if (path3DS != null && Directory.Exists(path = Path.Combine(path3DS, "filer", "UserSaveData")))
            {
                possiblePaths.AddRange(getSavesFromFolder(path, true));
            }

            // JKSV
            if (path3DS != null && Directory.Exists(path = Path.Combine(path3DS, "JKSV", "Saves")))
            {
                possiblePaths.AddRange(getSavesFromFolder(path, true));
            }

            // TWL Save Tool
            if (path3DS != null && Directory.Exists(path = Path.Combine(path3DS, "TWLSaveTool")))
            {
                possiblePaths.AddRange(getSavesFromFolder(path, false));
            }

            // FBI
            if (path3DS != null && Directory.Exists(path = Path.Combine(path3DS, "fbi", "save")))
            {
                possiblePaths.AddRange(getSavesFromFolder(path, false));
            }

            // CyberGadget (Cache)
            string pathCache = Util.GetCacheFolder();

            if (Directory.Exists(pathCache))
            {
                possiblePaths.AddRange(getSavesFromFolder(Path.Combine(pathCache), false));
            }

            // return newest save file path that is valid (oh man)
            return(possiblePaths.OrderByDescending(f => new FileInfo(f).LastWriteTime).FirstOrDefault(p => getVariantSAV(File.ReadAllBytes(p)).ChecksumsValid));
        }