source: OniSplit/BinImporter.cs@ 1182

Last change on this file since 1182 was 1114, checked in by iritscen, 5 years ago

Adding OniSplit source code (v0.9.99.0). Many thanks to Neo for all his work over the years.

File size: 1.1 KB
RevLine 
[1114]1using System;
2using System.IO;
3using Oni.Metadata;
4
5namespace Oni
6{
7 internal class BinImporter : Importer
8 {
9 public override void Import(string filePath, string outputDirPath)
10 {
11 using (var reader = new BinaryReader(filePath))
12 {
13 int tag = reader.ReadInt32();
14
15 if (!Enum.IsDefined(typeof(BinaryTag), tag))
16 throw new NotSupportedException(string.Format(".bin file with tag '{0:x}' is unuspported", tag));
17
18 var tagName = ((BinaryTag)tag).ToString();
19
20 BeginImport();
21
22 var bina = CreateInstance(TemplateTag.BINA, tagName + Path.GetFileNameWithoutExtension(filePath));
23
24 using (var writer = bina.OpenWrite())
25 {
26 writer.Write(reader.Length);
27 writer.Write(32);
28 }
29
30 RawWriter.Write(tag);
31 RawWriter.Write(reader.ReadBytes(reader.Length - 4));
32
33 Write(outputDirPath);
34 }
35 }
36 }
37}
Note: See TracBrowser for help on using the repository browser.