public FileIndex(string idxFile, string mulFile, int file)
{
string idxPath = null;
MulPath = null;
if (Files.MulPath == null)
Files.LoadMulPath();
if (Files.MulPath.Count > 0)
{
idxPath = Files.MulPath[idxFile.ToLower()];
MulPath = Files.MulPath[mulFile.ToLower()];
if (String.IsNullOrEmpty(idxPath))
idxPath = null;
else
{
if (String.IsNullOrEmpty(Path.GetDirectoryName(idxPath)))
idxPath = Path.Combine(Files.RootDir, idxPath);
if (!File.Exists(idxPath))
idxPath = null;
}
if (String.IsNullOrEmpty(MulPath))
MulPath = null;
else
{
if (String.IsNullOrEmpty(Path.GetDirectoryName(MulPath)))
MulPath = Path.Combine(Files.RootDir, MulPath);
if (!File.Exists(MulPath))
MulPath = null;
}
}
if ((idxPath != null) && (MulPath != null))
{
using (FileStream index = new FileStream(idxPath, FileMode.Open, FileAccess.Read, FileShare.Read))
{
Stream = new FileStream(MulPath, FileMode.Open, FileAccess.Read, FileShare.Read);
int count = (int)(index.Length / 12);
IdxLength = index.Length;
Index = new Entry3D[count];
GCHandle gc = GCHandle.Alloc(Index, GCHandleType.Pinned);
byte[] buffer = new byte[index.Length];
index.Read(buffer, 0, (int)index.Length);
Marshal.Copy(buffer, 0, gc.AddrOfPinnedObject(), (int)index.Length);
gc.Free();
}
}
else
{
Stream = null;
Index = new Entry3D[1];
return;
}
Entry5D[] patches = Verdata.Patches;
if (file > -1)
{
for (int i = 0; i < patches.Length; ++i)
{
Entry5D patch = patches[i];
if (patch.file == file && patch.index >= 0 && patch.index < Index.Length)
{
Index[patch.index].lookup = patch.lookup;
Index[patch.index].length = patch.length | (1 << 31);
Index[patch.index].extra = patch.extra;
}
}
}
}