67 lines
2.1 KiB
C#
Raw Normal View History

2016-11-12 19:02:48 +03:00
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 SonicAudioLib;
using SonicAudioLib.Archive;
using SonicAudioLib.IO;
using SonicAudioLib.CriMw;
using System.Xml;
namespace SonicAudioCmd
{
class Program
{
static void Main(string[] args)
{
2016-12-25 21:43:22 +03:00
if (args[0].EndsWith(".cpk"))
2016-11-12 19:02:48 +03:00
{
2016-12-25 21:43:22 +03:00
CriCpkArchive archive = new CriCpkArchive();
archive.Load(args[0]);
2016-12-31 15:56:10 +03:00
//archive.Print();
2016-12-25 21:43:22 +03:00
foreach (CriCpkEntry entry in archive)
2016-11-12 19:02:48 +03:00
{
2016-12-25 21:43:22 +03:00
using (Stream source = File.OpenRead(args[0]), substream = entry.Open(source))
2016-11-12 19:02:48 +03:00
{
2016-12-25 21:43:22 +03:00
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;
2016-11-12 19:02:48 +03:00
}
}
}
2016-12-25 21:43:22 +03:00
else
{
CriCpkArchive archive = new CriCpkArchive();
archive.Align = 16;
2016-12-31 15:56:10 +03:00
archive.Mode = CriCpkMode.Id;
2016-12-25 21:43:22 +03:00
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");
}
2016-11-12 19:02:48 +03:00
}
}
}