コード例 #1
0
        public void TestEntryReadingMethods()
        {
            using (ScsArchiveReader reader = new ScsArchiveReader(ExternalPaths.DefScsFilePath)) {
                IReadOnlyDictionary <ulong, HashFsEntry> entries = reader.GetEntries().Result;
                HashFsEntry                  rootEntry           = entries[HASH_ROOT_FOLDER];
                HashFsEntryReader            rootEntryReader     = new HashFsEntryReader(rootEntry);
                IEnumerable <HashFsFileName> names = rootEntryReader.ListFiles().Result;

                using (Stream s = rootEntryReader.GetStream()) {
                    byte[] streamData = new byte[rootEntry.UncompressedSize];

                    while (s.Position < streamData.Length)
                    {
                        s.Read(streamData, (int)s.Position, streamData.Length);
                    }

                    byte[] contentData = rootEntryReader.GetContent().Result;

                    CollectionAssert.AreEqual(streamData, contentData);

                    string contentDataString = Encoding.UTF8.GetString(contentData);
                    string contentString     = rootEntryReader.GetContent(Encoding.UTF8).Result;

                    Assert.AreEqual(contentDataString, contentString);

                    foreach (HashFsFileName n in names)
                    {
                        string realName = (n.IsDirectory ? "*" : "") + n.Name;

                        Assert.IsTrue(contentString.Contains(realName));
                    }
                }
            }
        }
コード例 #2
0
        public void TestGetDirectoryFileNames()
        {
            using (ScsArchiveReader reader = new ScsArchiveReader(ExternalPaths.DefScsFilePath)) {
                IReadOnlyDictionary <ulong, HashFsEntry> entries = reader.GetEntries().Result;
                HashFsEntry                  rootEntry           = entries[HASH_ROOT_FOLDER];
                HashFsEntryReader            rootEntryReader     = new HashFsEntryReader(rootEntry);
                IEnumerable <HashFsFileName> names = rootEntryReader.ListFiles().Result;

                Assert.AreEqual(1, (from HashFsFileName n in names where n.Name.Equals("def") select n).Count());
                Assert.AreEqual(0, (from HashFsFileName n in names where n.Name.Equals("egfoaepbwgp") select n).Count());
            }
        }