Class SgaFile
- Namespace
- OpenCompote.SGA
- Assembly
- OpenCompote.dll
Represents a file within a SGA archive.
public class SgaFile : SgaEntry
- Inheritance
-
SgaFile
- Inherited Members
Properties
CompressedSize
Gets the compressed size in bytes, of the file in the archive.
public uint CompressedSize { get; }
Property Value
Exceptions
- ObjectDisposedException
This file was deleted or the parent archive has been disposed.
Crc
Get the CRC(Cyclic redundant check) of the opened file. Only loaded when present in the archive. If the crc in newly open archive this property will be null. CRC is automatically calculated for sga versions which are using CRCs. CRCs are not automatically check when file is opened, but you can check the your self by opening the file.
public uint? Crc { get; }
Property Value
- uint?
Exceptions
- ObjectDisposedException
This file was deleted or the parent archive has been disposed.
Modified
Gets or sets the last write time of the file in the archive (UTC).
public DateTimeOffset? Modified { get; set; }
Property Value
Remarks
The value is always represented in UTC (offset +00:00).
This property will be null when opening an SGA V2 archive without file metadata present.
Modified is automatically set when you create a new file and every time the changed file stream is disposed.
Exceptions
- ObjectDisposedException
This file was deleted or the parent archive has been disposed.
- InvalidOperationException
The archive is opened in read-only mode.
Size
Gets the uncompressed size in bytes, of the file in the archive.
public uint Size { get; }
Property Value
Exceptions
- ObjectDisposedException
This file was deleted or the parent archive has been disposed.
StorageType
Gets or sets the file's storage type.
public StorageType StorageType { get; set; }
Property Value
Exceptions
- ObjectDisposedException
This file was deleted or the parent archive has been disposed.
- InvalidOperationException
The archive is opened in read-only mode.
- IOException
The entry is currently open for writing and storage type cannot be changed.
- ArgumentOutOfRangeException
The new value is not a valid option for StorageType.
Methods
ExtractToFile(string, bool)
Extracts this sgaFile in the archive to a file.
public void ExtractToFile(string destination, bool overwrite = false)
Parameters
destinationstringThe path of the folder to which will this file be exported.
overwriteboolif true, it overwrites an existing file; otherwise, it throws an exception when the file already exists.
Exceptions
- ArgumentException
Destination is null or whitespace.
- ObjectDisposedException
The SGA archive for this file has been disposed, or this file is deleted.
- IOException
The entry is currently open for writing.
- InvalidOperationException
Archive SgaMode value is invalid.
Open()
Opens the file and gets the file contents.
public Stream Open()
Returns
- Stream
Read only Stream when the parent archive is open in Read mode or writable Stream when the parent archive is open in Create or Write mode, with the file contents.
Remarks
In Create or Write mode the updates to Size, CompressedSize, Crc and Modified properties are done only when the returned Stream is disposed.
Exceptions
- ObjectDisposedException
The SGA archive for this file has been disposed, or this file is deleted.
- IOException
The entry is currently open for writing.
- InvalidOperationException
Archive SgaMode value is invalid.