Show / Hide Table of Contents

Class FileProxy

This class abstracts a disk file or memory buffer to an object that can be emitted and read using binary streams.

Inheritance
Object
FileProxy
Namespace: DaggerfallConnect.Utility
Assembly: Assembly-CSharp.dll
Syntax
public class FileProxy

Constructors

| Improve this Doc View Source

FileProxy()

Default constructor.

Declaration
public FileProxy()
| Improve this Doc View Source

FileProxy(Byte[], String)

Assign byte array constructor.

Declaration
public FileProxy(byte[] data, string name)
Parameters
Type Name Description
Byte[] data

Byte array to assign (usage will be set to FileUsage.useMemory).

String name

Name, filename, or path to describe memory buffer.

| Improve this Doc View Source

FileProxy(String, FileUsage, Boolean)

Load constructor.

Declaration
public FileProxy(string filePath, FileUsage usage, bool readOnly)
Parameters
Type Name Description
String filePath

Absolute path to 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 Source

Buffer

Gets byte array when using FileUsage.UseMemory.

Declaration
public byte[] Buffer { get; }
Property Value
Type Description
Byte[]
| Improve this Doc View Source

Directory

Get directory path of managed file without filename.

Declaration
public string Directory { get; }
Property Value
Type Description
String
| Improve this Doc View Source

FileName

Get filename of managed file without path.

Declaration
public string FileName { get; }
Property Value
Type Description
String
| Improve this Doc View Source

FilePath

Get full path and filename of managed file. Derived from filename for disk files, or specified at construction for managed files.

Declaration
public string FilePath { get; }
Property Value
Type Description
String
| Improve this Doc View Source

FileStream

Gets file stream when using FileUsage.UseDisk

Declaration
public FileStream FileStream { get; }
Property Value
Type Description
FileStream
| Improve this Doc View Source

LastException

Gets last exception thrown.

Declaration
public Exception LastException { get; }
Property Value
Type Description
Exception
| Improve this Doc View Source

Length

Length of managed file in bytes.

Declaration
public int Length { get; }
Property Value
Type Description
Int32
| Improve this Doc View Source

ReadOnly

Access allowed to file.

Declaration
public bool ReadOnly { get; }
Property Value
Type Description
Boolean
| Improve this Doc View Source

Usage

Get the file usage in effect for this managed file.

Declaration
public FileUsage Usage { get; }
Property Value
Type Description
FileUsage

Methods

| Improve this Doc View Source

beReadInt16(BinaryReader)

Reads next 2 bytes as a big-endian Int16.

Declaration
public short beReadInt16(BinaryReader reader)
Parameters
Type Name Description
BinaryReader reader

Source reader.

Returns
Type Description
Int16

Big-endian Int16

| Improve this Doc View Source

beReadInt32(BinaryReader)

Reads next 4 bytes as a big-endian Int32.

Declaration
public int beReadInt32(BinaryReader reader)
Parameters
Type Name Description
BinaryReader reader

Source reader.

Returns
Type Description
Int32

Big-endian Int32.

| Improve this Doc View Source

beReadUInt16(BinaryReader)

Reads next 2 bytes as a big-endian UInt16.

Declaration
public ushort beReadUInt16(BinaryReader reader)
Parameters
Type Name Description
BinaryReader reader

Source reader.

Returns
Type Description
UInt16

Big-endian UInt16.

| Improve this Doc View Source

beReadUInt32(BinaryReader)

Reads next 4 bytes as a big-endian UInt32.

Declaration
public uint beReadUInt32(BinaryReader reader)
Parameters
Type Name Description
BinaryReader reader

Source reader.

Returns
Type Description
UInt32

Big-endian Int32.

| Improve this Doc View Source

Close()

Close open file and free memory used for buffer.

Declaration
public void Close()
| Improve this Doc View Source

endianSwapUInt16(UInt16)

Swaps an unsigned 16-bit big-endian value to little-endian.

Declaration
public ushort endianSwapUInt16(ushort value)
Parameters
Type Name Description
UInt16 value

Source reader.

Returns
Type Description
UInt16

Little-endian UInt16.

| Improve this Doc View Source

endianSwapUInt32(UInt32)

Swaps an unsigned 32-bit big-endian value to little-endian.

Declaration
public uint endianSwapUInt32(uint value)
Parameters
Type Name Description
UInt32 value

Source reader.

Returns
Type Description
UInt32

Little-endian UInt32.

| Improve this Doc View Source

FindString(String, Int32)

Find a string pattern inside file.

Declaration
public int FindString(string pattern, int position = 0)
Parameters
Type Name Description
String pattern

String pattern to search for. Converted to UTF8 and is case sensitive.

Int32 position

Position to begin search.

Returns
Type Description
Int32

Index of pattern found or -1 if not found.

| Improve this Doc View Source

GetBytes()

Gets a byte array from file.

Declaration
public byte[] GetBytes()
Returns
Type Description
Byte[]
| Improve this Doc View Source

GetBytes(Int64, Int32)

Gets a byte array from file.

Declaration
public byte[] GetBytes(long position, int length)
Parameters
Type Name Description
Int64 position

Start position.

Int32 length

Read length.

Returns
Type Description
Byte[]
| Improve this Doc View Source

GetReader()

Gets a binary reader to managed file.

Declaration
public BinaryReader GetReader()
Returns
Type Description
BinaryReader

BinaryReader to managed file with UTF8 encoding.

| Improve this Doc View Source

GetReader(Int64)

Get a binary reader to managed file starting at the specified position.

Declaration
public BinaryReader GetReader(long position)
Parameters
Type Name Description
Int64 position

Position to start in stream (number of bytes from start of file).

Returns
Type Description
BinaryReader

BinaryReader to managed file with UTF8 encoding and set to specified position.

| Improve this Doc View Source

GetWriter()

Gets a binary writer to managed file.

Declaration
public BinaryWriter GetWriter()
Returns
Type Description
BinaryWriter

BinaryReader to managed file with UTF8 encoding.

| Improve this Doc View Source

GetWriter(Int64)

Get a binary writer to managed file starting at the specified position.

Declaration
public BinaryWriter GetWriter(long position)
Parameters
Type Name Description
Int64 position

Position to start in stream (number of bytes from start of file).

Returns
Type Description
BinaryWriter

BinaryReader to managed file with UTF8 encoding and set to specified position.

| Improve this Doc View Source

Load(Byte[], String)

Load a binary array.

Declaration
public void Load(byte[] data, string name)
Parameters
Type Name Description
Byte[] data

Byte array to assign (usage will be set to FileUsage.useMemory).

String name

Name, filename, or path to describe memory buffer.

| Improve this Doc View Source

Load(String, FileUsage, Boolean)

Load a file.

Declaration
public bool Load(string filePath, FileUsage usage = FileUsage.UseMemory, bool readOnly = true)
Parameters
Type Name Description
String filePath

Absolute path to 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.

Returns
Type Description
Boolean

True if successful, otherwise false.

| Improve this Doc View Source

ReadCString(Int32, Int32)

Reads a UTF8 string of bytes from the managed file.

Declaration
public string ReadCString(int position, int readLength)
Parameters
Type Name Description
Int32 position

Position to start reading in file (number of bytes from start of file).

Int32 readLength

Number of bytes to read (length=0 for null-terminated.)

Returns
Type Description
String

String composed from bytes read (all NULLs are discarded).

| Improve this Doc View Source

ReadCString(BinaryReader, Int32)

Reads a UTF8 string of length bytes from the binary reader. String may or may not be null terminated.

Declaration
public static string ReadCString(BinaryReader reader, int readLength = 0)
Parameters
Type Name Description
BinaryReader reader

Source reader.

Int32 readLength

Number of bytes to read (0 for null-terminated).

Returns
Type Description
String

String composed from bytes read.

| Improve this Doc View Source

ReadCStringSkip(BinaryReader, Int32, Int32)

Reads a UTF8 string from binary reader then sets reader position to start + skipLength. Handles a special case where string may be null terminated but still require fixed byte stride.

Declaration
public static string ReadCStringSkip(BinaryReader reader, int readLength, int skipLength)
Parameters
Type Name Description
BinaryReader reader

Source reader.

Int32 readLength

Number of bytes to read (0 for null-terminated).

Int32 skipLength

Number of bytes to skip from start position after read.

Returns
Type Description
String

String composed from bytes read (all NULLs are discarded).

  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX