Table of Contents

Class SgaArchiveFile

Namespace
OpenCompote.SGA
Assembly
OpenCompote.dll

Provides static methods for opening, creating, and extracting SGA archives.

public class SgaArchiveFile
Inheritance
SgaArchiveFile
Inherited Members

Methods

Create(Stream, SgaVersion, bool)

Creates new SGA archive from existing stream, in the specified SgaVersion.

public static SgaArchive Create(Stream existingStream, SgaVersion version, bool leaveOpen)

Parameters

existingStream Stream

Empty Stream for the archive.

version SgaVersion

Version of the new SGA archive.

leaveOpen bool

true to leave the existingStream open after sgaArchive is disposed. false to close the existingStream when the archive is disposed.

Returns

SgaArchive

The newly opened SGA archive.

Remarks

The new existingStream is always created with mode set to Create.

When you set the version to null or any other undefined value ArgumentException is thrown.

Not all version of Sga archive file are supported. For more info see status page.

The existingStream must be empty and support reading, writing and seeking. If the existingStream does not meet this criteria an ArgumentException is thrown.

Create(string, SgaVersion, bool)

Creates a new SGA archive at the path specified by sourceFileName in the specified version.

public static SgaArchive Create(string sourceFileName, SgaVersion version, bool overwrite = false)

Parameters

sourceFileName string

The path to the new SGA archive, specified as a relative or absolute path. Relative path is relative to the current working directory.

version SgaVersion

Version of the new SGA archive.

overwrite bool

If true, it overwrites an existing file; otherwise, it throws an exception when the file already exists.

Returns

SgaArchive

The newly opened SGA archive.

Remarks

The new 'SgaArchive' is always created with mode set to Create.

When you set the version to null or any other undefined value ArgumentException is thrown.

Not all version of Sga archive file are supported. For more info see status page.

Open(Stream, SgaMode, bool)

Opens a SGA archive from existing stream, in the specified 'SgaMode' mode.

public static SgaArchive Open(Stream existingStream, SgaMode mode, bool leaveOpen = false)

Parameters

existingStream Stream

Stream containing the SGA archive.

mode SgaMode

One of the enumeration values that specifies the actions that are allowed on the opened archive.

leaveOpen bool

true to leave the existingStream open after sgaArchive is disposed. false to close the existingStream when the archive is disposed.

Returns

SgaArchive

The opened SGA archive.

Remarks

existingStream must support reading and seeking and if the mode is set to Write also reading. If the existingStream does not meet this criteria an ArgumentException is thrown.

This function cannot be used with mode set to Create. For creating a new archive use the Create(Stream, SgaVersion, bool) function. When you set the mode to Create an ArgumentException is thrown.

When you set the mode to null or any other undefined value ArgumentException is thrown.

When you set the mode to Read or Write, the archive is opened with Open from the FileMode enumeration as the file mode value. If the archive does not exist, a FileNotFoundException exception is thrown.

If the mode is Write, the archive entries can be modified. If the mode is Read, you can only read the archive entries. Attempt to write to the archive will cause NotSupportedException exception.

The archive SgaVersion is automatically detected based on the input file. If the version cannot be detected, a InvalidDataException is thrown.

Open(string, SgaMode)

Opens a SGA Archive at the specific source path, in the specified mode.

public static SgaArchive Open(string sourceFileName, SgaMode mode)

Parameters

sourceFileName string

The path to the SGA archive to open, specified as a relative or absolute path. Relative path is relative to the current working directory.

mode SgaMode

One of the enumeration values that specifies the actions that are allowed on the opened archive.

Returns

SgaArchive

The opened SGA archive.

Remarks

This function cannot be used with mode set to Create. For creating a new archive use the Create(string, SgaVersion, bool) function. When you set the mode to Create an ArgumentException is thrown.

When you set the mode to null or any other undefined value ArgumentException is thrown.

When you set the mode to Read or Write, the archive is opened with Open from the FileMode enumeration as the file mode value. If the archive does not exist, a FileNotFoundException exception is thrown.

If the mode is Write, the archive entries can be modified. If the mode is Read, you can only read the archive entries. Attempt to write to the archive will cause NotSupportedException exception.

The archive SgaVersion is automatically detected based on the input file. If the version cannot be detected, a InvalidDataException is thrown.