Skip to content

Commit f49cd41

Browse files
committed
Archive files are all lowercase
1 parent ef88450 commit f49cd41

File tree

1 file changed

+32
-5
lines changed

1 file changed

+32
-5
lines changed

XbTool/XbTool/Xb2/ArchiveFileSystem.cs

+32-5
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public ArchiveFileSystem(IFile headerFile, IFile dataFile)
9393

9494
public IDirectory OpenDirectory(string path, OpenDirectoryMode mode)
9595
{
96-
path = PathTools.Normalize(path);
96+
path = PathTools.Normalize(path).ToLowerInvariant();
9797

9898
if (!FileTable.TryOpenDirectory(path, out FindPosition position))
9999
{
@@ -105,7 +105,7 @@ public IDirectory OpenDirectory(string path, OpenDirectoryMode mode)
105105

106106
public IFile OpenFile(string path, OpenMode mode)
107107
{
108-
path = PathTools.Normalize(path);
108+
path = PathTools.Normalize(path).ToLowerInvariant();
109109

110110
if (!FileTable.TryOpenFile(path, out RomFileInfo romFileInfo))
111111
{
@@ -135,21 +135,21 @@ public IFile OpenFile(string path, OpenMode mode)
135135

136136
public bool DirectoryExists(string path)
137137
{
138-
path = PathTools.Normalize(path);
138+
path = PathTools.Normalize(path).ToLowerInvariant();
139139

140140
return FileTable.TryOpenDirectory(path, out FindPosition _);
141141
}
142142

143143
public bool FileExists(string path)
144144
{
145-
path = PathTools.Normalize(path);
145+
path = PathTools.Normalize(path).ToLowerInvariant();
146146

147147
return FileTable.TryOpenFile(path, out RomFileInfo _);
148148
}
149149

150150
public DirectoryEntryType GetEntryType(string path)
151151
{
152-
path = PathTools.Normalize(path);
152+
path = PathTools.Normalize(path).ToLowerInvariant();
153153

154154
if (FileExists(path)) return DirectoryEntryType.File;
155155
if (DirectoryExists(path)) return DirectoryEntryType.Directory;
@@ -223,6 +223,33 @@ public static void DecryptArh(byte[] file)
223223
Buffer.BlockCopy(filei, 0, file, 0, file.Length);
224224
}
225225

226+
public FileInfo GetFileInfo(string filename)
227+
{
228+
int cur = 0;
229+
Node curNode = Nodes[cur];
230+
231+
for (int i = 0; i < filename.Length; i++)
232+
{
233+
if (curNode.Next < 0) break;
234+
235+
int next = curNode.Next ^ char.ToLower(filename[i]);
236+
Node nextNode = Nodes[next];
237+
if (nextNode.Prev != cur) return null;
238+
cur = next;
239+
curNode = nextNode;
240+
}
241+
242+
int offset = -curNode.Next;
243+
while (StringTable[offset] != 0)
244+
{
245+
offset++;
246+
}
247+
offset++;
248+
249+
int fileId = BitConverter.ToInt32(StringTable, offset);
250+
return FileInfo[fileId];
251+
}
252+
226253
private class Node
227254
{
228255
public int Next { get; set; }

0 commit comments

Comments
 (0)