-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move all archive implementations to shared
- Loading branch information
1 parent
94b115a
commit 9071a5e
Showing
12 changed files
with
126 additions
and
801 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
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,25 +1,89 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.IO; | ||
using Yura.Shared.IO; | ||
|
||
namespace Yura.Shared.Archive | ||
{ | ||
public class DeusExArchive : ArchiveFile | ||
{ | ||
private uint _alignment; | ||
|
||
public DeusExArchive(ArchiveOptions options) : base(options) | ||
{ | ||
} | ||
|
||
public override void Open() | ||
{ | ||
throw new NotImplementedException(); | ||
var stream = File.OpenRead(Options.Path); | ||
var reader = new DataReader(stream, Options.Endianness); | ||
|
||
// Read the header | ||
_alignment = reader.ReadUInt32(); | ||
|
||
// Skip over the config name | ||
reader.Position += 64; | ||
|
||
// Read the number of files | ||
var numRecords = reader.ReadUInt32(); | ||
|
||
if (numRecords > 1_000_000) | ||
{ | ||
throw new ArgumentException("Bigfile has more than a million files, did you select the right endianness?"); | ||
} | ||
|
||
// Read the file name hashes | ||
var hashes = new uint[numRecords]; | ||
|
||
for (var i = 0; i < numRecords; i++) | ||
{ | ||
hashes[i] = reader.ReadUInt32(); | ||
} | ||
|
||
// Read the file records | ||
for (var i = 0; i < numRecords; i++) | ||
{ | ||
var record = new Record | ||
{ | ||
Hash = hashes[i], | ||
|
||
Size = reader.ReadUInt32(), | ||
Offset = reader.ReadUInt32(), | ||
Specialisation = reader.ReadUInt32(), | ||
CompressedSize = reader.ReadUInt32(), | ||
}; | ||
|
||
Records.Add(record); | ||
} | ||
|
||
stream.Close(); | ||
} | ||
|
||
public override byte[] Read(ArchiveRecord record) | ||
{ | ||
throw new NotImplementedException(); | ||
var file = record as Record; | ||
|
||
// Calculate the location of the file | ||
var offset = (long)file.Offset << 11; | ||
var part = offset / _alignment; | ||
|
||
var path = GetFilePart((int)part); | ||
|
||
// Read the file | ||
var stream = File.OpenRead(path); | ||
var data = new byte[file.Size]; | ||
|
||
stream.Position = offset % _alignment; | ||
stream.ReadExactly(data); | ||
|
||
stream.Close(); | ||
|
||
return data; | ||
} | ||
|
||
private class Record : ArchiveRecord | ||
{ | ||
public uint Offset { get; set; } | ||
public uint CompressedSize { get; set; } | ||
} | ||
} | ||
} |
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
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
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.