Esempio n. 1
0
 public void readFilesSpreads(FSARArchive FARch, FSARFileEntryInfo[] FileHeaders, byte[] FileData)
 {
     for (int i = 0; i < FARch.Header.FileTableObjects; i++)
     {
         FARch.Files[i] = FileHeaders[i].GetFileSpreads(FileData);
     }
 }
Esempio n. 2
0
        static void Main(string[] args)
        {
            Stopwatch Time = new Stopwatch();

            Time.Start();
            Byte[]     Header = new Byte[0x20];
            FSARFile[] Files;
            Byte[]     FFArray = File.ReadAllBytes("test.far");

            // Read the header
            Buffer.BlockCopy(FFArray, 0, Header, 0, 0x20);
            FSARInfo HeaderInfo = FSARRead.ParseHeader(Header);

            // Parse the File entries
            Byte[] FARTable = new Byte[HeaderInfo.FileTableEnd - 0x20];
            Buffer.BlockCopy(FFArray, 0x20, FARTable, 0, FARTable.Length);
            FSARFileEntryInfo[] FARFiles = FSARRead.GetFileEntries(FARTable, HeaderInfo.FileTableObjects);

            // Read the data of all the files
            Files = new FSARFile[HeaderInfo.FileTableObjects];
            Byte[] FilesData = new Byte[FFArray.Length - HeaderInfo.FileTableEnd];
            Buffer.BlockCopy(FFArray, HeaderInfo.FileTableEnd, FilesData, 0, FilesData.Length);
            for (int i = 0; i < HeaderInfo.FileTableObjects; i++)
            {
                Console.WriteLine(FARFiles[i].Path);
                Files[i] = FARFiles[i].GetFile(FilesData);
            }
            FSARArchive FARArch = new FSARArchive();

            FARArch.Files  = Files;
            FARArch.Header = HeaderInfo;
            Time.Stop();
            UInt64 TS = (UInt64)Time.ElapsedMilliseconds;

            Console.WriteLine("It took {0}ms to extract the files from Test.far", TS);
            foreach (FSARFile CurrentFile in FARArch.Files)
            {
                string OutStr = String.Format("test_far\\{0}", CurrentFile.FileHeader.Path);
                Directory.CreateDirectory(String.Format("test_far\\{0}", CurrentFile.FileHeader.Directory));
                File.WriteAllBytes(OutStr, CurrentFile.UncompressedData);
            }
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            var Timer = new Stopwatch();

            Timer.Start();

            // FSARMount file.far Z
            string FarPath = "Game.far" /* args[0] */;
            // char DriveLetter = 'Z' /* args[1] */;

            FSARArchive FARch = new FSARArchive(), FARch2 = new FSARArchive();

            FSARFileEntryInfo[] FileHeaders;
            Byte[] FSARData = File.ReadAllBytes(FarPath);
            Byte[] Header   = new Byte[0x20];
            Byte[] FileTable;
            Byte[] FileData;

            // Read header
            FSARHelper.fastCopyBlock(FSARData, 0, Header, 0, Header.Length);
            FARch.Header = FSARRead.ParseHeader(Header);

            // Parse the file headers
            FileTable = new Byte[FARch.Header.FileTableEnd];
            FSARHelper.fastCopyBlock(FSARData, 0x20, FileTable, 0, FileTable.Length);
            FileHeaders = FSARRead.GetFileEntries(FileTable, FARch.Header.FileTableObjects);

            // Copy the files' data to the right byte array for parsing and get the files array ready
            FARch.Files = new FSARFile[FARch.Header.FileTableObjects];
            FileData    = new Byte[FSARData.Length - FARch.Header.FileTableEnd];
            FSARHelper.fastCopyBlock(FSARData, FARch.Header.FileTableEnd, FileData, 0, FileData.Length);

            // Read the files
            for (int i = 0; i < FARch.Header.FileTableObjects; i++)
            {
                FARch.Files[i] = FileHeaders[i].GetFile(FileData);
            }
            Timer.Stop();
            var ReadTime = Timer.Elapsed.TotalMilliseconds;

            Console.WriteLine(string.Format("Parsed files: {0}", FARch.Header.FileTableObjects));
            Console.WriteLine(string.Format("Completed FSARArchive class in {0}ms", ReadTime));
            Console.WriteLine("Time to reconstruct the file");
            Timer.Restart();

            Byte[] ReconstructedArch = FSARWrite.MakeFSARArchive(FARch);
            File.WriteAllBytes("Game2.far", ReconstructedArch);

            Timer.Stop();
            var WriteTime = Timer.Elapsed.TotalMilliseconds;

            Console.WriteLine(string.Format("Completed writing archive in {0}ms", WriteTime));

            FSARData = File.ReadAllBytes("Out.far");
            // Read header
            FSARHelper.fastCopyBlock(FSARData, 0, Header, 0, Header.Length);
            FARch2.Header = FSARRead.ParseHeader(Header);

            // Parse the file headers
            FileTable = new Byte[FARch2.Header.FileTableEnd];
            FSARHelper.fastCopyBlock(FSARData, 0x20, FileTable, 0, FileTable.Length);
            FileHeaders = FSARRead.GetFileEntries(FileTable, FARch2.Header.FileTableObjects);

            // Copy the files' data to the right byte array for parsing and get the files array ready
            FARch2.Files = new FSARFile[FARch.Header.FileTableObjects];
            FileData     = new Byte[FSARData.Length - FARch2.Header.FileTableEnd];
            FSARHelper.fastCopyBlock(FSARData, FARch2.Header.FileTableEnd, FileData, 0, FileData.Length);

            // Read the files
            for (int i = 0; i < FARch2.Header.FileTableObjects; i++)
            {
                FARch2.Files[i] = FileHeaders[i].GetFile(FileData);
            }
            Console.WriteLine(FARch == FARch2);
        }