-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSFS.bt
74 lines (54 loc) · 1.79 KB
/
SFS.bt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//------------------------------------------------
//--- 010 Editor v14.0.1 Binary Template
//
// File: SFS.bt
// Authors: Simon Davies (insomnious) & Nexus Mods
// Version: 1.0.0
// Purpose:
// Category:
// File Mask:
// ID Bytes:
// History:
//------------------------------------------------
LittleEndian();
typedef struct {
char magic[4] <style=sHeading1Accent>; //0x04034b50
uint version;
uint64 chunkSizesOffset;
uint64 unknown0;
uint64 compressedDataOffset;
uint64 uncompressedDataSize;
float version2;
uint unknown1;
uint64 sizeUncompressedChunks;
uint64 paddingSize;
uint unknown2;
char compressionType[4];
local uint64 numberOfchunks = Ceil((float) header.uncompressedDataSize / header.sizeUncompressedChunks);
uint compressedChunkSizes[numberOfchunks];
} HEADER;
typedef struct {
byte chunk[header.compressedChunkSizes[i]];
} CHUNK;
HEADER header;
local int64 fileSize = FileSize();
// go to start of data
FSeek(header.compressedDataOffset);
local int i;
local int total;
local int offset;
local int paddedSize;
for(i = 0; i < header.numberOfchunks; i++ ) {
offset = FTell();
paddedSize = padToNearestSize(header.paddingSize, header.compressedChunkSizes[i]);
Printf("offset = %d, size = %d, padded_size = %d\n", offset, header.compressedChunkSizes[i], paddedSize);
CHUNK chunk; // new chunk
FSeek(offset); // reset back to chunk beginning
FSkip(paddedSize); // seek to start of next chunk
}
local uint64 compressedDataSize = fileSize - header.compressedDataOffset;
// Function to pad a size to the nearest 16 bytes
int padToNearestSize(int paddingSize, int size) {
local int maxPadSize = paddingSize - 1;
return (size + maxPadSize) & ~maxPadSize;
}