mirror of
https://github.com/crskycode/GARbro.git
synced 2024-10-23 07:38:16 +08:00
virtual file system migration.
This commit is contained in:
parent
ddfd5a117d
commit
4d48b25512
@ -53,9 +53,9 @@ namespace GameRes.Formats.Nexton
|
||||
public override ArcFile TryOpen (ArcView file)
|
||||
{
|
||||
string lstname = file.Name + ".lst";
|
||||
if (!File.Exists (lstname))
|
||||
if (!VFS.FileExists (lstname))
|
||||
return null;
|
||||
using (var lst = new ArcView (lstname))
|
||||
using (var lst = VFS.OpenView (lstname))
|
||||
{
|
||||
List<Entry> dir = null;
|
||||
try
|
||||
|
@ -45,10 +45,9 @@ namespace GameRes.Formats.BlackCyc
|
||||
if (!file.Name.EndsWith (".gpk", StringComparison.InvariantCultureIgnoreCase))
|
||||
return null;
|
||||
var gtb_name = Path.ChangeExtension (file.Name, "gtb");
|
||||
var gtb_info = new FileInfo (gtb_name);
|
||||
if (!gtb_info.Exists)
|
||||
if (!VFS.FileExists (gtb_name))
|
||||
return null;
|
||||
using (var gtb = new ArcView (gtb_name))
|
||||
using (var gtb = VFS.OpenView (gtb_name))
|
||||
{
|
||||
int count = gtb.View.ReadInt32 (0);
|
||||
if (!IsSaneCount (count))
|
||||
|
@ -45,14 +45,14 @@ namespace GameRes.Formats.BlackCyc
|
||||
if (!file.Name.EndsWith (".vpk", StringComparison.InvariantCultureIgnoreCase))
|
||||
return null;
|
||||
var vtb_name = Path.ChangeExtension (file.Name, "vtb");
|
||||
var vtb_info = new FileInfo (vtb_name);
|
||||
if (!vtb_info.Exists)
|
||||
if (!VFS.FileExists (vtb_name))
|
||||
return null;
|
||||
int count = (int)(vtb_info.Length / 0x0C) - 1;
|
||||
var vtb_entry = VFS.FindFile (vtb_name);
|
||||
int count = (int)(vtb_entry.Size / 0x0C) - 1;
|
||||
if (!IsSaneCount (count))
|
||||
return null;
|
||||
|
||||
using (var vtb = new ArcView (vtb_name))
|
||||
using (var vtb = VFS.OpenView (vtb_entry))
|
||||
{
|
||||
vtb.View.Reserve (0, (uint)vtb.MaxOffset);
|
||||
uint index_offset = 0;
|
||||
|
@ -51,12 +51,14 @@ namespace GameRes.Formats.Eagls
|
||||
public override ArcFile TryOpen (ArcView file)
|
||||
{
|
||||
string idx_name = Path.ChangeExtension (file.Name, ".idx");
|
||||
var idx_info = new FileInfo (idx_name);
|
||||
if (!idx_info.Exists || idx_info.Length > 0xfffff || idx_info.Length < 10000)
|
||||
if (!VFS.FileExists (idx_name))
|
||||
return null;
|
||||
var idx_entry = VFS.FindFile (idx_name);
|
||||
if (idx_entry.Size > 0xfffff || idx_entry.Size < 10000)
|
||||
return null;
|
||||
|
||||
byte[] index;
|
||||
using (var idx = new ArcView (idx_name))
|
||||
using (var idx = VFS.OpenView (idx_entry))
|
||||
index = DecryptIndex (idx);
|
||||
int index_offset = 0;
|
||||
int entry_size = index.Length / 10000;
|
||||
|
@ -49,15 +49,13 @@ namespace GameRes.Formats.Ffa
|
||||
public override ArcFile TryOpen (ArcView file)
|
||||
{
|
||||
string lst_name = Path.ChangeExtension (file.Name, ".lst");
|
||||
if (lst_name == file.Name)
|
||||
if (lst_name == file.Name || !VFS.FileExists (lst_name))
|
||||
return null;
|
||||
var lst_info = new FileInfo (lst_name);
|
||||
if (!lst_info.Exists)
|
||||
var lst_entry = VFS.FindFile (lst_name);
|
||||
int count = (int)(lst_entry.Size/0x16);
|
||||
if (count > 0xffff || count*0x16 != lst_entry.Size)
|
||||
return null;
|
||||
int count = (int)(lst_info.Length/0x16);
|
||||
if (count > 0xffff || count*0x16 != lst_info.Length)
|
||||
return null;
|
||||
using (var lst = new ArcView (lst_name))
|
||||
using (var lst = VFS.OpenView (lst_entry))
|
||||
{
|
||||
var dir = new List<Entry> (count);
|
||||
uint index_offset = 0;
|
||||
|
@ -84,7 +84,7 @@ namespace GameRes.Formats.Kaguya
|
||||
{
|
||||
string ari_name = Path.ChangeExtension (file.Name, "ari");
|
||||
List<Entry> dir = null;
|
||||
if (file.Name != ari_name && File.Exists (ari_name))
|
||||
if (file.Name != ari_name && VFS.FileExists (ari_name))
|
||||
dir = ReadAriIndex (file, ari_name);
|
||||
if (null == dir || 0 == dir.Count)
|
||||
dir = BuildIndex (file);
|
||||
@ -94,7 +94,7 @@ namespace GameRes.Formats.Kaguya
|
||||
List<Entry> ReadAriIndex (ArcView file, string ari_name)
|
||||
{
|
||||
long arc_offset = 4;
|
||||
using (var ari = new ArcView (ari_name))
|
||||
using (var ari = VFS.OpenView (ari_name))
|
||||
{
|
||||
long index_offset = 0;
|
||||
while (index_offset+4 < ari.MaxOffset)
|
||||
|
@ -320,8 +320,8 @@ namespace GameRes.Formats.Lucifen
|
||||
|
||||
void ImportKeys (string source_name)
|
||||
{
|
||||
var script_lpk = Path.Combine (Path.GetDirectoryName (source_name), "SCRIPT.LPK");
|
||||
using (var script_file = new ArcView (script_lpk))
|
||||
var script_lpk = VFS.CombinePath (Path.GetDirectoryName (source_name), "SCRIPT.LPK");
|
||||
using (var script_file = VFS.OpenView (script_lpk))
|
||||
using (var script_arc = Open (ScriptName, script_file, CurrentScheme, null))
|
||||
{
|
||||
if (null == script_arc)
|
||||
|
@ -28,7 +28,6 @@ using System.IO;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.Composition;
|
||||
using System.Diagnostics;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
@ -178,9 +177,9 @@ namespace GameRes.Formats.Majiro
|
||||
string name = Encodings.cp932.GetString (name_bin, 0, name_bin.Length-1);
|
||||
string dir_name = Path.GetDirectoryName (meta.FileName);
|
||||
name = Path.Combine (dir_name, name);
|
||||
if (File.Exists (name))
|
||||
if (VFS.FileExists (name))
|
||||
{
|
||||
using (var base_file = File.OpenRead (name))
|
||||
using (var base_file = VFS.OpenSeekableStream (name))
|
||||
{
|
||||
var base_info = ReadMetaData (base_file) as RctMetaData;
|
||||
if (null != base_info && 0 == base_info.AddSize
|
||||
|
@ -58,9 +58,7 @@ namespace GameRes.Formats.Malie
|
||||
|
||||
public override ImageMetaData ReadMetaData (Stream stream)
|
||||
{
|
||||
var tex = new DirectoryInfo ("tex");
|
||||
if (!tex.Exists)
|
||||
return null;
|
||||
var tex = VFS.FindFile ("tex");
|
||||
using (var reader = new StreamReader (stream, Encoding.UTF8, false, 2048, true))
|
||||
{
|
||||
reader.ReadLine(); // skip signature
|
||||
@ -101,7 +99,10 @@ namespace GameRes.Formats.Malie
|
||||
foreach (var file in line.Split (','))
|
||||
{
|
||||
if (!string.IsNullOrEmpty (file))
|
||||
tiles.Add (new DziTile { X = x, Y = y, FileName = Path.Combine (tex.Name, file + ".png") });
|
||||
{
|
||||
var filename = VFS.CombinePath (tex.Name, file + ".png");
|
||||
tiles.Add (new DziTile { X = x, Y = y, FileName = filename });
|
||||
}
|
||||
x += 256;
|
||||
}
|
||||
y += 256;
|
||||
@ -131,7 +132,7 @@ namespace GameRes.Formats.Malie
|
||||
int actual_height = 0;
|
||||
foreach (var tile in meta.Tiles.First())
|
||||
{
|
||||
using (var file = File.OpenRead (tile.FileName))
|
||||
using (var file = VFS.OpenStream (VFS.FindFile (tile.FileName)))
|
||||
{
|
||||
var decoder = new PngBitmapDecoder (file,
|
||||
BitmapCreateOptions.None, BitmapCacheOption.OnLoad);
|
||||
|
@ -50,14 +50,14 @@ namespace GameRes.Formats.Elf
|
||||
public override ArcFile TryOpen (ArcView file)
|
||||
{
|
||||
string pak_name = Path.ChangeExtension (file.Name, "pak");
|
||||
if (pak_name == file.Name || !File.Exists (pak_name))
|
||||
if (pak_name == file.Name || !VFS.FileExists (pak_name))
|
||||
return null;
|
||||
var file_map = GetFileMap (pak_name);
|
||||
if (null == file_map)
|
||||
return null;
|
||||
string base_name = Path.GetFileNameWithoutExtension (pak_name);
|
||||
|
||||
using (var pak = new ArcView (pak_name))
|
||||
using (var pak = VFS.OpenView (pak_name))
|
||||
{
|
||||
if (0x00646568 != pak.View.ReadUInt32 (0))
|
||||
return null;
|
||||
|
Loading…
Reference in New Issue
Block a user