private void RebuildBinaryFile(IArchiveBinaryFile sourceFile, IArchiveDirectory destinationDirectory, RageArchiveEncryption7 archiveEncryption)
        {
            foreach (var handler in BinaryFileHandlers)
            {
                if (handler.CanRebuild(sourceFile))
                {
                    handler.Rebuild(sourceFile, destinationDirectory, archiveEncryption);
                    return;
                }
            }

            var ms = new MemoryStream();

            sourceFile.Export(ms);
            ms.Position = 0;

            var buf = new byte[ms.Length];

            ms.Position = 0;
            ms.Read(buf, 0, buf.Length);

            var newF = destinationDirectory.CreateBinaryFile();

            newF.Name = sourceFile.Name;

            newF.Import(new MemoryStream(buf));
            newF.IsEncrypted = sourceFile.IsEncrypted;

            if (sourceFile.IsCompressed)
            {
                newF.IsCompressed     = sourceFile.IsCompressed;
                newF.UncompressedSize = sourceFile.UncompressedSize;
            }
        }
Exemple #2
0
        /// <summary>
        /// Imports a file.
        /// </summary>
        public void Import(IArchiveDirectory directory, string fileName)
        {
            var fi = new FileInfo(fileName);

            var fs    = new FileStream(fileName, FileMode.Open);
            var fsR   = new DataReader(fs);
            var ident = fsR.ReadUInt32();

            fs.Close();


            // delete existing file
            var existingFile = directory.GetFile(fi.Name);

            if (existingFile != null)
            {
                directory.DeleteFile(existingFile);
            }


            if (ident == 0x07435352)
            {
                var newF = directory.CreateResourceFile();
                newF.Name = fi.Name;
                newF.Import(fileName);
            }
            else
            {
                var newF = directory.CreateBinaryFile();
                newF.Name = fi.Name;
                newF.Import(fileName);
            }
        }
        private void RebuildArchiveFile(IArchiveBinaryFile sourceFile, IArchiveDirectory destinationDirectory)
        {
            var fileStream   = sourceFile.GetStream();
            var inputArchive = RageArchiveWrapper7.Open(fileStream, sourceFile.Name);
            var newF         = destinationDirectory.CreateBinaryFile();

            newF.Name = sourceFile.Name;
            var outStream     = newF.GetStream();
            var outputArchive = RageArchiveWrapper7.Create(outStream, sourceFile.Name);

            RebuildDictionary(inputArchive.Root, outputArchive.Root, inputArchive.archive_.Encryption);
            outputArchive.FileName            = sourceFile.Name;
            outputArchive.archive_.Encryption = inputArchive.archive_.Encryption;
            outputArchive.Flush();
        }
Exemple #4
0
        /// <summary>
        /// Imports a file.
        /// </summary>
        public void Import(IArchiveDirectory directory, string fileName)
        {
            var fi = new FileInfo(fileName);

            var fs = new FileStream(fileName, FileMode.Open);
            var fsR = new DataReader(fs);
            var ident = fsR.ReadUInt32();
            fs.Close();

            // delete existing file
            var existingFile = directory.GetFile(fi.Name);
            if (existingFile != null)
                directory.DeleteFile(existingFile);

            if (ident == 0x07435352)
            {

                var newF = directory.CreateResourceFile();
                newF.Name = fi.Name;
                newF.Import(fileName);

            }
            else
            {

                var newF = directory.CreateBinaryFile();
                newF.Name = fi.Name;
                newF.Import(fileName);

            }
        }