Exemplo n.º 1
0
        static void ConvertEntry(ref PAKToolArchiveEntry entry)
        {
            using (MemoryStream mStream = new MemoryStream(entry.Data))
            {
                if (PAKToolArchiveFile.VerifyFileType(mStream))
                {
                    PAKToolArchiveFile subPak = new PAKToolArchiveFile(mStream);
                    for (int i = 0; i < subPak.EntryCount; i++)
                    {
                        PAKToolArchiveEntry subEntry = subPak.Entries[i];
                        ConvertEntry(ref subEntry);
                        subPak.Entries[i] = subEntry;
                    }

                    entry = new PAKToolArchiveEntry(entry.Name, ListArchiveFile.Create(subPak).GetBytes());
                }
            }
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                Console.WriteLine("No input specified.");
                Console.WriteLine("Usage:");
                Console.WriteLine(" Enter path to an ARC file to convert it to a PAK file OR");
                Console.WriteLine(" Enter path to a PAK file to convert it to an ARC file.");
                Console.WriteLine("Press any key to continue.");
                Console.ReadKey();
                return;
            }

            if (ListArchiveFile.VerifyFileType(args[0]))
            {
                ListArchiveFile arc = new ListArchiveFile(args[0]);
                for (int i = 0; i < arc.EntryCount; i++)
                {
                    ListArchiveFileEntry entry = arc.Entries[i];
                    ConvertEntry(ref entry);
                    arc.Entries[i] = entry;
                }

                PAKToolArchiveFile pak = PAKToolArchiveFile.Create(arc);
                pak.Save(args[0] + ".pak");
            }
            else if (PAKToolArchiveFile.VerifyFileType(args[0]))
            {
                PAKToolArchiveFile pak = new PAKToolArchiveFile(args[0]);
                for (int i = 0; i < pak.EntryCount; i++)
                {
                    PAKToolArchiveEntry entry = pak.Entries[i];
                    ConvertEntry(ref entry);
                    pak.Entries[i] = entry;
                }

                ListArchiveFile arc = ListArchiveFile.Create(pak);
                arc.Save(args[0] + ".arc");
            }
            else
            {
                Console.WriteLine("File supplied is not an ARC or PAK file!");
            }
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                Console.WriteLine("No input specified.");
                Console.WriteLine("Usage:");
                Console.WriteLine(" Enter path to PAK file to extract it to a folder of the same name.");
                Console.WriteLine(" Enter path to directory to pack into a PAK.");
                Console.WriteLine("Press any key to continue.");
                Console.ReadKey();
                return;
            }

            if (Path.HasExtension(args[0]))
            {
                if (!PAKToolArchiveFile.VerifyFileType(args[0]))
                {
                    Console.WriteLine("This is not a proper pak file!");
                    if (ListArchiveFile.VerifyFileType(args[0]))
                    {
                        Console.WriteLine("Detected format: Vita .arc archive.");
                    }
                    return;
                }

                PAKToolArchiveFile pak = new PAKToolArchiveFile(args[0]);
                string path = Path.GetFileNameWithoutExtension(args[0]);
                Directory.CreateDirectory(path);
                for (int i = 0; i < pak.EntryCount; i++)
                {
                    File.WriteAllBytes(path + "//" + pak.Entries[i].Name, pak.Entries[i].Data);
                }
            }
            else if (!Path.HasExtension(args[0]))
            {
                PAKToolArchiveFile pak = PAKToolArchiveFile.Create(args[0]);
                pak.Save(Path.GetFileName(args[0]) + ".PAK");
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Create a new archive file using a <see cref="ListArchiveFile"/>.
        /// </summary>
        /// <param name="arc">The <see cref="ListArchiveFile"/> to load into the <see cref="PAKToolArchiveFile"/>.</param>
        /// <returns>A newly created archive.</returns>
        public static PAKToolArchiveFile Create(ListArchiveFile arc)
        {
            PAKToolArchiveFile pak = new PAKToolArchiveFile();

            for (int i = 0; i < arc.EntryCount; i++)
            {
                ListArchiveFileEntry arcEntry = arc.Entries[i];
                pak.Entries.Add(new PAKToolArchiveEntry(arcEntry.Name, arcEntry.Data));
            }

            return pak;
        }
Exemplo n.º 5
0
        /*********************************/
        /* Base wrapper method overrides */
        /*********************************/
        internal override void RebuildWrappedObject()
        {
            var archive = new PAKToolArchiveFile();
            foreach (ResourceWrapper node in Nodes)
            {
                archive.Entries.Add(new PAKToolArchiveEntry(node.Text, node.GetMemoryStream()));
            }

            m_wrappedObject = archive;
            m_isDirty = false;
        }
Exemplo n.º 6
0
 /***************/
 /* Constructor */
 /***************/
 public PAKToolFileWrapper(string text, PAKToolArchiveFile bin) 
     : base(text, bin, SupportedFileType.PAKToolArchiveFile, false)
 {
 }