Beispiel #1
0
        public EventBlockDiff(string f1, string f2)
        {
            if (!SanityCheckFiles(f1, f2))
            {
                return;
            }
            var s1 = SaveUtil.GetVariantSAV(f1);
            var s2 = SaveUtil.GetVariantSAV(f2);

            Diff(s1, s2);
        }
Beispiel #2
0
        public EventBlockDiff(string f1, string f2)
        {
            if (!SanityCheckFiles(f1, f2))
            {
                return;
            }
            var s1 = SaveUtil.GetVariantSAV(f1);
            var s2 = SaveUtil.GetVariantSAV(f2);

            if (s1 == null || s2 == null || s1.GetType() != s2.GetType())
            {
                Message = MsgSaveDifferentTypes;
                return;
            }
            Diff(s1, s2);
        }
Beispiel #3
0
        /// <summary>
        /// Gets all detectable save files ordered by most recently saved (by file write time).
        /// </summary>
        /// <param name="drives">List of drives on the host machine.</param>
        /// <param name="detect">Detect save files stored in common SD card homebrew locations.</param>
        /// <param name="extra">Paths to check in addition to the default paths</param>
        /// <returns>Valid save files, if any.</returns>
        public static IEnumerable <SaveFile> GetSaveFiles(IReadOnlyList <string> drives, bool detect, IEnumerable <string> extra)
        {
            var paths  = detect ? GetFoldersToCheck(drives, extra) : extra;
            var result = GetSaveFilePathsFromFolders(paths, out var possiblePaths);

            if (!result)
            {
                yield break;
            }

            var byMostRecent = possiblePaths.OrderByDescending(File.GetLastWriteTimeUtc);

            foreach (var s in byMostRecent)
            {
                var sav = SaveUtil.GetVariantSAV(s);
                if (sav != null)
                {
                    yield return(sav);
                }
            }
        }
Beispiel #4
0
        public static bool IsFileTooSmall(long length) => length < 0x20; // bigger than PK1

        /// <summary>
        /// Tries to get an <see cref="SaveFile"/> object from the input parameters.
        /// </summary>
        /// <param name="data">Binary data</param>
        /// <param name="sav">Output result</param>
        /// <returns>True if file object reference is valid, false if none found.</returns>
        public static bool TryGetSAV(byte[] data, out SaveFile?sav)
        {
            sav = SaveUtil.GetVariantSAV(data);
            return(sav != null);
        }