mirror of
https://github.com/blueskythlikesclouds/SonicAudioTools.git
synced 2025-02-13 09:12:35 +01:00
73 lines
2.4 KiB
Plaintext
73 lines
2.4 KiB
Plaintext
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Linq;
|
||
|
using System.Text;
|
||
|
using System.IO;
|
||
|
using System.IO.Compression;
|
||
|
using System.ComponentModel;
|
||
|
using System.Collections;
|
||
|
using System.Threading;
|
||
|
|
||
|
using SonicAudioLib;
|
||
|
using SonicAudioLib.Archive;
|
||
|
using SonicAudioLib.IO;
|
||
|
using SonicAudioLib.CriMw;
|
||
|
|
||
|
using System.Xml;
|
||
|
|
||
|
namespace SonicAudioCmd
|
||
|
{
|
||
|
class Program
|
||
|
{
|
||
|
static void Main(string[] args)
|
||
|
{
|
||
|
if (args[0].EndsWith(".cpk"))
|
||
|
{
|
||
|
CriCpkArchive archive = new CriCpkArchive();
|
||
|
archive.Load(args[0]);
|
||
|
//archive.Print();
|
||
|
|
||
|
foreach (CriCpkEntry entry in archive)
|
||
|
{
|
||
|
new Thread(new ThreadStart(delegate
|
||
|
{
|
||
|
using (Stream source = File.OpenRead(args[0]), substream = entry.Open(source))
|
||
|
{
|
||
|
Console.WriteLine("Extracting {0}{1}", entry.DirectoryName, entry.Name);
|
||
|
|
||
|
FileInfo fileInfo = new FileInfo(Path.Combine(Path.GetFileNameWithoutExtension(args[0]), entry.DirectoryName != null ? entry.DirectoryName : "", entry.Name != null ? entry.Name : entry.Id.ToString() + ".bin"));
|
||
|
fileInfo.Directory.Create();
|
||
|
using (Stream destination = fileInfo.Create())
|
||
|
{
|
||
|
substream.CopyTo(destination);
|
||
|
}
|
||
|
fileInfo.LastWriteTime = entry.UpdateDateTime;
|
||
|
}
|
||
|
})).Start();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
else
|
||
|
{
|
||
|
CriCpkArchive archive = new CriCpkArchive();
|
||
|
archive.Align = 16;
|
||
|
archive.Mode = CriCpkMode.Id;
|
||
|
|
||
|
uint id = 0;
|
||
|
foreach (string file in Directory.GetFiles(args[0], "*", SearchOption.AllDirectories))
|
||
|
{
|
||
|
CriCpkEntry entry = new CriCpkEntry();
|
||
|
entry.Id = id;
|
||
|
entry.Name = Path.GetFileName(file);
|
||
|
entry.DirectoryName = Path.GetDirectoryName(file.Replace(args[0] + "\\", ""));
|
||
|
entry.FilePath = new FileInfo(file);
|
||
|
archive.Add(entry);
|
||
|
id++;
|
||
|
}
|
||
|
|
||
|
archive.Save(args[0] + ".cpk");
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|