Beispiel #1
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);
            }
        }
Beispiel #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);

            }
        }
Beispiel #3
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;
         }
     }
 }
Beispiel #4
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());
 }