parent
e6d74c3167
commit
b3d344b002
|
@ -16,10 +16,11 @@ namespace BizHawk.Client.Common
|
||||||
{
|
{
|
||||||
private IArchive? _archive;
|
private IArchive? _archive;
|
||||||
|
|
||||||
private IEnumerable<IArchiveEntry> EnumerateArchiveFiles()
|
private IEnumerable<(IArchiveEntry Entry, int ArchiveIndex)> EnumerateArchiveFiles()
|
||||||
{
|
{
|
||||||
if (_archive == null) throw new ObjectDisposedException(nameof(SharpCompressArchiveFile));
|
if (_archive == null) throw new ObjectDisposedException(nameof(SharpCompressArchiveFile));
|
||||||
return _archive.Entries.Where(e => !e.IsDirectory);
|
return _archive.Entries.Select(static (e, i) => (Entry: e, ArchiveIndex: i))
|
||||||
|
.Where(static tuple => !tuple.Entry.IsDirectory);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SharpCompressArchiveFile(string path) => _archive = ArchiveFactory.Open(path, new());
|
public SharpCompressArchiveFile(string path) => _archive = ArchiveFactory.Open(path, new());
|
||||||
|
@ -47,9 +48,9 @@ namespace BizHawk.Client.Common
|
||||||
var entries = EnumerateArchiveFiles().ToList();
|
var entries = EnumerateArchiveFiles().ToList();
|
||||||
for (var i = 0; i < entries.Count; i++)
|
for (var i = 0; i < entries.Count; i++)
|
||||||
{
|
{
|
||||||
var entry = entries[i];
|
var (entry, archiveIndex) = entries[i];
|
||||||
if (entry.Key == null) return null;
|
if (entry.Key == null) return null;
|
||||||
outFiles.Add(new HawkArchiveFileItem(entry.Key.Replace('\\', '/'), entry.Size, i, i));
|
outFiles.Add(new HawkArchiveFileItem(entry.Key.Replace('\\', '/'), size: entry.Size, index: i, archiveIndex: archiveIndex));
|
||||||
}
|
}
|
||||||
return outFiles;
|
return outFiles;
|
||||||
}
|
}
|
||||||
|
|
|
@ -170,7 +170,7 @@ namespace BizHawk.Common
|
||||||
ArchiveMemberPath = _archiveItems[index].Name; // TODO - maybe go through our own list of names? maybe not, its indices don't match...
|
ArchiveMemberPath = _archiveItems[index].Name; // TODO - maybe go through our own list of names? maybe not, its indices don't match...
|
||||||
Util.DebugWriteLine($"{nameof(HawkFile)} bound {CanonicalFullPath}");
|
Util.DebugWriteLine($"{nameof(HawkFile)} bound {CanonicalFullPath}");
|
||||||
if (_boundStream.Length is 0) Console.WriteLine("bound file is 0 bytes long?");
|
if (_boundStream.Length is 0) Console.WriteLine("bound file is 0 bytes long?");
|
||||||
BoundIndex = archiveIndex;
|
BoundIndex = index;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue