コード例 #1
0
        public async Task ReadArchiveAsync_GameDat_Loaded()
        {
            var fs         = new FileSystem();
            var reader     = new NefsReader(fs);
            var headerPath = Path.Combine(DirtRally2Path, @"dirtrally2.exe");
            var dataPath   = Path.Combine(DirtRally2Path, @"game\game.dat");

            var offset = 0x107B9B0;
            var nefs   = await reader.ReadArchiveAsync(headerPath, (uint)offset, dataPath, this.progress);

            // Not really verifying anything here, but useful to set breakpoint and inspect objects
            Assert.NotNull(nefs);
        }
コード例 #2
0
        public async Task ReadArchiveAsync_EncrpytedCarArchive()
        {
            var         fs     = new FileSystem();
            var         reader = new NefsReader(fs);
            var         path   = Path.Combine(DirtRally2Path, @"cars\c4r.nefs");
            NefsArchive nefs   = null;

            using (var stream = fs.File.OpenRead(path))
            {
                nefs = await reader.ReadArchiveAsync(path, this.progress);
            }

            Assert.Equal(98, nefs.Items.Count);
        }
コード例 #3
0
        public async Task ReadArchiveAsync_GameNefsArchive()
        {
            var         fs     = new FileSystem();
            var         reader = new NefsReader(fs);
            var         path   = Path.Combine(DirtRally2Path, @"game\game.nefs");
            NefsArchive nefs   = null;

            using (var stream = fs.File.OpenRead(path))
            {
                nefs = await reader.ReadArchiveAsync(path, this.progress);
            }

            // Not sure if this is the actual count, there are errors when reading game.nefs
            Assert.Equal(0x445, nefs.Items.Count);
        }
コード例 #4
0
        public async Task WriteArchiveAsync_ArchiveNotModified_ArchiveWritten()
        {
            var sourcePath = @"C:\archive.nefs";
            var destPath   = @"C:\dest.nefs";

            this.fileSystem.AddFile(sourcePath, new MockFileData("hi"));
            var sourceArchive = TestArchiveNotModified.Create(sourcePath);
            var writer        = this.CreateWriter();
            var archive       = await writer.WriteArchiveAsync(@"C:\dest.nefs", sourceArchive, new NefsProgress());

            Assert.Equal(sourceArchive.Items.Count, archive.Items.Count);

            // Try to read archive again
            var reader      = new NefsReader(this.fileSystem);
            var readArchive = await reader.ReadArchiveAsync(destPath, new NefsProgress());

            Assert.Equal(sourceArchive.Items.Count, readArchive.Items.Count);
        }