This repository has been archived by the owner on Feb 4, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optimize BundleExporter and fix DirectoryRecord reading
- Loading branch information
Showing
2 changed files
with
78 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,78 @@ | ||
using System; | ||
using System.IO; | ||
using System.Linq; | ||
|
||
namespace BundleExporter | ||
{ | ||
class Program | ||
{ | ||
static void Main() | ||
{ | ||
if (!File.Exists("_.index.bin")) | ||
{ | ||
Console.WriteLine("File not found: _.index.bin"); | ||
Console.WriteLine("Click enter to exit . . ."); | ||
Console.ReadLine(); | ||
return; | ||
} | ||
if (!File.Exists("LibBundle.dll")) | ||
{ | ||
Console.WriteLine("File not found: oo2core_8_win64.dll"); | ||
Console.WriteLine("Click enter to exit . . ."); | ||
Console.ReadLine(); | ||
return; | ||
} | ||
if (!File.Exists("oo2core_8_win64.dll")) | ||
{ | ||
Console.WriteLine("File not found: oo2core_8_win64.dll"); | ||
Console.WriteLine("Click enter to exit . . ."); | ||
Console.ReadLine(); | ||
return; | ||
} | ||
|
||
var ic = new LibBundle.IndexContainer("_.index.bin"); | ||
Console.WriteLine("Found:"); | ||
Console.WriteLine(ic.Bundles.Length.ToString() + " BundleRecords"); | ||
Console.WriteLine(ic.Directorys.Length.ToString() + " DirectoryRecords"); | ||
Console.WriteLine(ic.Files.Length.ToString() + " FileRecords"); | ||
Console.WriteLine(""); | ||
|
||
var ExistFiles = ic.Files.Where(o => File.Exists(o.bundleRecord.Name)); | ||
Console.Write("Exporting files . . . ("); | ||
int count = 0; | ||
var str = "/" + ExistFiles.Count().ToString() + ")"; | ||
foreach (var f in ExistFiles) | ||
{ | ||
count++; | ||
Console.CursorLeft = 23; | ||
Console.Write(count); | ||
Console.Write(str); | ||
try | ||
{ | ||
var path = ic.Hashes[f.Hash]; | ||
if (!Directory.Exists(Path.GetDirectoryName(path))) | ||
Directory.CreateDirectory(Path.GetDirectoryName(path)); | ||
var fi = File.Create(path); | ||
fi.Write(f.Read(), 0, f.Size); | ||
} | ||
catch (System.Collections.Generic.KeyNotFoundException) { } | ||
} | ||
Console.WriteLine(Environment.NewLine); | ||
Console.WriteLine("Click enter to exit . . ."); | ||
Console.ReadLine(); | ||
} | ||
} | ||
using System; | ||
using System.IO; | ||
using System.Linq; | ||
|
||
namespace BundleExporter | ||
{ | ||
class Program | ||
{ | ||
static void Main() | ||
{ | ||
if (!File.Exists("_.index.bin")) | ||
{ | ||
Console.WriteLine("File not found: _.index.bin"); | ||
Console.WriteLine("Click enter to exit . . ."); | ||
Console.ReadLine(); | ||
return; | ||
} | ||
if (!File.Exists("LibBundle.dll")) | ||
{ | ||
Console.WriteLine("File not found: oo2core_8_win64.dll"); | ||
Console.WriteLine("Click enter to exit . . ."); | ||
Console.ReadLine(); | ||
return; | ||
} | ||
if (!File.Exists("oo2core_8_win64.dll")) | ||
{ | ||
Console.WriteLine("File not found: oo2core_8_win64.dll"); | ||
Console.WriteLine("Click enter to exit . . ."); | ||
Console.ReadLine(); | ||
return; | ||
} | ||
|
||
var ic = new LibBundle.IndexContainer("_.index.bin"); | ||
Console.WriteLine("Found:"); | ||
Console.WriteLine(ic.Bundles.Length.ToString() + " BundleRecords"); | ||
Console.WriteLine(ic.Files.Length.ToString() + " FileRecords"); | ||
Console.WriteLine(ic.Directorys.Length.ToString() + " DirectoryRecords"); | ||
var ExistBundle = ic.Bundles.Where(o => File.Exists(o.Name)); | ||
Console.WriteLine(ExistBundle.Count().ToString() + " bundle.bin"); | ||
Console.WriteLine(""); | ||
|
||
int count = 0; | ||
foreach (var b in ExistBundle) | ||
count += b.Files.Count; | ||
Console.Write("Exporting files . . . ("); | ||
var str = "/" + count.ToString() + ")"; | ||
count = 0; | ||
foreach (var b in ExistBundle) | ||
{ | ||
var data = b.Bundle.Read(); | ||
foreach (var f in b.Files) | ||
{ | ||
count++; | ||
Console.CursorLeft = 23; | ||
Console.Write(count); | ||
Console.Write(str); | ||
try | ||
{ | ||
var path = ic.Hashes[f.Hash]; | ||
Directory.CreateDirectory(Path.GetDirectoryName(path)); | ||
var by = new byte[f.Size]; | ||
data.Position = f.Offset; | ||
data.Read(by, 0, f.Size); | ||
File.WriteAllBytes(path, by); | ||
} | ||
catch (Exception e) | ||
{ | ||
Console.Error.WriteLine(e.ToString()); | ||
} | ||
} | ||
data.Close(); | ||
} | ||
Console.WriteLine(Environment.NewLine); | ||
Console.WriteLine("Click enter to exit . . ."); | ||
Console.ReadLine(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters