AssemblyCSharp.FileHelper.VerifyExpandedArchive C# (CSharp) Method

VerifyExpandedArchive() public static method

public static VerifyExpandedArchive ( string baseDirectory, Predicate shouldCheck = null, string manifestName = "manifest.txt" ) : bool
baseDirectory string
shouldCheck Predicate
manifestName string
return bool
        public static bool VerifyExpandedArchive(string baseDirectory, Predicate<string> shouldCheck = null, string manifestName = "manifest.txt")
        {
            var manifestPath = Path.Combine(baseDirectory, manifestName);
            if (!File.Exists(manifestPath))
            {
            return false;
            }

            var manifestHashPath = Path.Combine(baseDirectory, '.' + manifestName);
            if (!File.Exists(manifestHashPath))
            {
            return false;
            }

            if (!CompareHashes(File.ReadAllBytes(manifestHashPath), GetMD5OfFile(manifestPath, manifestName)))
            {
            return false;
            }

            using (var reader = new StreamReader(manifestPath))
            {
            for (var line = reader.ReadLine(); line != null; line = reader.ReadLine())
            {
                line = line.Trim();
                if (!string.IsNullOrEmpty(line))
                {
                    var nameAndFingerprint = line.Split('\t');
                    var entryPath = Path.Combine(baseDirectory, nameAndFingerprint[0]);

                    if (shouldCheck == null || shouldCheck(entryPath))
                    {
                        if (!File.Exists(entryPath))
                        {
                            return false;
                        }

                        var fileHash = GetMD5OfFile(entryPath, manifestName);
                        if (GetFingerprint(fileHash) != nameAndFingerprint[1])
                        {
                            return false;
                        }
                    }
                }
            }
            }

            return true;
        }