/// <summary>
        /// Merges two archives into a single archive.
        /// </summary>
        public static void Merge(string ar, string merge)
        {
            GensArchive arc    = new GensArchive();
            GensArchive tmpArc = new GensArchive();
            string      arl    = Paths.ReplaceFilename(ar, $"{Path.GetFileNameWithoutExtension(Path.GetFileNameWithoutExtension(ar))}.arl");

            CreateBackup(ar);
            Decompress.DecompressBySystem(ar);
            Decompress.DecompressBySystem(arl);
            CreateBackup(arl);

            foreach (string split in arc.GetSplitArchivesList(ar))
            {
                CreateBackup(split);
                Decompress.DecompressBySystem(split);
            }

            foreach (string split in arc.GetSplitArchivesList(ar))
            {
                arc.Load(split);
            }

            tmpArc.Load(merge);

            foreach (var entry in tmpArc.Data)
            {
                arc.Data.Remove(arc.Data.Find(x => x.Name.Equals(entry.Name)));
                arc.Data.Add(entry);
            }

            arc.Save(ar, true, 99999999);
        }
Exemplo n.º 2
0
        // Methods
        /// <summary>
        /// Packs a PFD and generates a PFI.
        /// </summary>
        /// <param name="input">The directory to pack into a PFD</param>
        /// <param name="output">The directory to output PFD and PFI files.
        /// Auto-detected if none is given.</param>
        /// <param name="pfdPadding">How much padding the generated PFD should have.</param>
        public static void PackPFD(string input, string output = null,
                                   uint pfdPadding             = 2048)
        {
            // Get output Directory
            var info = new DirectoryInfo(input);

            if (string.IsNullOrEmpty(output))
            {
                output = info.Parent.FullName;
            }

            Directory.CreateDirectory(output);

            // Pack PFD
            var    pfd     = new GensArchive();
            string pfdPath = Path.Combine(output,
                                          info.Name + GensArchive.PFDExtension);

            pfd.Padding = pfdPadding;
            pfd.AddDirectory(input);
            pfd.Save(pfdPath, overwrite: true);

            // Generate PFI
            var    pfi     = new GensPFI(pfd);
            string pfiPath = Path.Combine(output,
                                          info.Name + Extension);

            pfi.Save(pfiPath, true);
        }