Class BsaFile
Connects to a Daggerfall BSA file and extracts records as binary data.
Namespace: DaggerfallConnect.Arena2
Assembly: Assembly-CSharp.dll
Syntax
public class BsaFile
Constructors
| Improve this Doc View SourceBsaFile()
Default constructor.
Declaration
public BsaFile()
BsaFile(String, FileUsage, Boolean)
Load constructor.
Declaration
public BsaFile(string filePath, FileUsage usage, bool readOnly)
Parameters
Type | Name | Description |
---|---|---|
String | filePath | Absolute path to BSA file. |
FileUsage | usage | Specify if file will be accessed from disk, or loaded into RAM. |
Boolean | readOnly | File will be read-only if true, read-write if false. |
Properties
| Improve this Doc View SourceCount
Number records in the loaded BSA file.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
Int32 |
DirectoryType
Type of directory used for this BSA file.
Declaration
public BsaFile.DirectoryTypes DirectoryType { get; }
Property Value
Type | Description |
---|---|
BsaFile.DirectoryTypes |
Methods
| Improve this Doc View SourceGetRecordBytes(Int32)
Retrieves a record as a byte array.
Declaration
public byte[] GetRecordBytes(int record)
Parameters
Type | Name | Description |
---|---|---|
Int32 | record | Index of record. |
Returns
Type | Description |
---|---|
Byte[] | Byte array containing record data. |
GetRecordId(Int32)
Gets ID of a number record. This method is valid only for BSA files with a number-based directory.
Declaration
public uint GetRecordId(int record)
Parameters
Type | Name | Description |
---|---|---|
Int32 | record | Index of record. |
Returns
Type | Description |
---|---|
UInt32 | ID of record. |
GetRecordIndex(String)
Finds index of a named record.
Declaration
public int GetRecordIndex(string name)
Parameters
Type | Name | Description |
---|---|---|
String | name | Name to search for. |
Returns
Type | Description |
---|---|
Int32 | Index of name, or -1 if not found. |
GetRecordLength(Int32)
Gets length of a record in bytes.
Declaration
public int GetRecordLength(int record)
Parameters
Type | Name | Description |
---|---|---|
Int32 | record | Index of record. |
Returns
Type | Description |
---|---|
Int32 | Length of records in bytes. |
GetRecordName(Int32)
Gets name of a record as a string. This method is valid for BSA files with either a number or name-based directory.
Declaration
public string GetRecordName(int record)
Parameters
Type | Name | Description |
---|---|---|
Int32 | record | Name of record. |
Returns
Type | Description |
---|---|
String | Name of record as string. |
GetRecordPosition(Int32)
Get position (offset) of record in BSA file.
Declaration
public long GetRecordPosition(int record)
Parameters
Type | Name | Description |
---|---|---|
Int32 | record | Index of record |
Returns
Type | Description |
---|---|
Int64 |
Load(String, FileUsage, Boolean, PatchList)
Load BSA file.
Declaration
public bool Load(string filePath, FileUsage usage, bool readOnly, PatchList filePatch = null)
Parameters
Type | Name | Description |
---|---|---|
String | filePath | Absolute path to BSA file. |
FileUsage | usage | Specify if file will be accessed from disk, or loaded into RAM. |
Boolean | readOnly | File will be read-only if true, read-write if false. |
PatchList | filePatch | An optional list of patches to apply to file memory buffer. |
Returns
Type | Description |
---|---|
Boolean | True if successful, otherwise false. |
RewriteRecord(Int32, Byte[])
Save new record data back to BSA file. WARNING: This will modify the BSA file. Ensure you have backups. BSA file must have been opened with ReadOnly flag disabled.
Declaration
public void RewriteRecord(int record, byte[] buffer)
Parameters
Type | Name | Description |
---|---|---|
Int32 | record | The record to save back. |
Byte[] | buffer | The data to save back. This must be the same length as record data. |