Ejemplo n.º 1
0
        public IGameDataEntry GetEntry(string name)
        {
            var file = m_directory.GetFile(name);

            if (file != null)
            {
                if (file.Name.EndsWith(".rpf"))
                {
                    var binaryFile = (IArchiveBinaryFile)file;

                    return(new ArchiveDirectoryEntry(RageArchiveWrapper7.Open(binaryFile.GetStream(), binaryFile.Name).Root, binaryFile.Name));
                }

                return(new ArchiveFileEntry(file));
            }

            var directory = m_directory.GetDirectory(name);

            if (directory != null)
            {
                return(new ArchiveDirectoryEntry(directory));
            }

            throw new FileNotFoundException();
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 3
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);

            }
        }
Ejemplo n.º 4
0
 private void Handle(IArchiveDirectory root, RpfListBuilder.InnerFile file, string name)
 {
     switch (file.Action)
     {
         case ContentAction.Delete:
             var archiveFile = root.GetFile(name);
             if (archiveFile != null)
                 root.DeleteFile(archiveFile);
             break;
         case ContentAction.Import:
         {
             if (!_config.TreatImportsAsInserts)
                 break;
             NewImport(root, file, file.FilePath, name);
             break;
         }
         case ContentAction.Insert:
         {
             NewImport(root, file, file.FilePath, name);
             break;
         }
     }
 }
Ejemplo n.º 5
0
 private void Handle(IArchiveDirectory root, RpfListBuilder.InnerRpf innerRpf,
     string name)
 {
     var rpf = root.GetFile(name);
     // IMPORTANT: The RPF must have the exact filename like original or it seems to make the RPF corrupt (loading either in RageLib, or in OIV)
     var tmpRpf = _tempPath.GetChildFileWithName(name);
     if (tmpRpf.Exists)
         tmpRpf.FileInfo.Delete();
     try
     {
         rpf.Export(tmpRpf.ToString());
         WriteModdedArchive(innerRpf, tmpRpf);
         NewImport(root, innerRpf, tmpRpf, name);
     }
     finally
     {
         tmpRpf.FileInfo.Delete();
     }
 }
Ejemplo n.º 6
0
 private static void NewImport(IArchiveDirectory root, RpfListBuilder.IFileContent fc, IAbsoluteFilePath tmpRpf,
     string name)
 {
     var existingFile = root.GetFile(name);
     var af = root.CreateArchiveFile(tmpRpf.ToString(),
         fc.Type == FileType.Default && existingFile != null ? DetermineType(existingFile) : fc.Type);
     if (existingFile != null)
         root.DeleteFile(existingFile);
     //af.IsCompressed = true;
     af.Name = name;
     af.Import(tmpRpf.ToString());
 }