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.

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.

Exceptions

ArgumentNullException

The existingStream parameter is null.

ArgumentException

The existingStream does not support reading, writing or seeking.

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.

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

Exceptions

ArgumentNullException

The sourceFileName parameter is null.

CreateFromDirectory(string, Stream, SgaVersion, StorageType, bool)

Creates a SGA archive in the specified stream that contains the files and directories from the specified directory.

public static void CreateFromDirectory(string sourceDirectoryName, Stream destination, SgaVersion version, StorageType defaultStorageType, bool leaveOpen = false)

Parameters

sourceDirectoryName string

The path to the directory containing the drives to be archived.

destination Stream

Empty Stream for the archive.

version SgaVersion

Version of the new SGA archive.

defaultStorageType StorageType

Default storage type that should be used while importing files.

leaveOpen bool

true to leave the destination open after this method finishes. false to close the destination when this method finishes.

Exceptions

ArgumentException

sourceDirectoryName is an empty string or invalid path.

ArgumentNullException

sourceDirectoryName is null.

-OR-

destination is null.

IOException

The directory or one of its entries could not be accessed or imported.

CreateFromDirectory(string, string, SgaVersion, StorageType, bool)

Creates a SGA archive that contains the files and directories from the specified directory.

public static void CreateFromDirectory(string sourceDirectoryName, string destinationArchiveFileName, SgaVersion version, StorageType defaultStorageType, bool overwrite = false)

Parameters

sourceDirectoryName string

The path to the directory to be archived.

destinationArchiveFileName string

The path of the archive to be created

version SgaVersion

Version of the new SGA archive.

defaultStorageType StorageType

Default storage type that should be used while importing files.

overwrite bool

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

Exceptions

ArgumentException

sourceDirectoryName is an empty string or invalid path.

-OR-

destinationArchiveFileName is an empty string or invalid path.

ArgumentNullException

destinationArchiveFileName is null.

-OR-

sourceDirectoryName is null.

IOException

The directory or one of its entries could not be accessed or imported.

ExtractToDirectory(Stream, string, bool, bool)

Extracts all the files in the specified sga archive to a directory on the file system.

public static void ExtractToDirectory(Stream existingStream, string destinationDirectoryName, bool leaveOpen = false, bool overwrite = false)

Parameters

existingStream Stream

Stream containing the SGA archive.

destinationDirectoryName string

The path to the destination directory to which the archive will be exported. If the directory is missing it creates it.

leaveOpen bool

true to leave the existingStream open after this function. false to close the existingStream when this method finishes.

overwrite bool

true to overwrite files; false otherwise.

Exceptions

ArgumentNullException

The existingStream or destinationDirectoryName parameter is null.

ArgumentException

The destinationDirectoryName parameter is empty string or invalid path./>.

ExtractToDirectory(string, string, bool)

Extracts all the files in the specified sga archive to a directory on the file system.

public static void ExtractToDirectory(string sourceFileName, string destinationDirectoryName, bool overwrite = false)

Parameters

sourceFileName string

The path on the file system to the archive that is to be extracted.

destinationDirectoryName string

The path to the destination directory to which the archive will be exported. If the directory is missing it creates it.

overwrite bool

true to overwrite files; false otherwise.

Exceptions

ArgumentNullException

The sourceFileName or destinationDirectoryName parameter is null.

ArgumentException

The sourceFileName or destinationDirectoryName is empty string or invalid path./>.

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 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.

Exceptions

ArgumentNullException

The existingStream parameter is null.

ArgumentException

The existingStream does not support reading, writing or seeking, or mode is set to Create.

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 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.

Exceptions

ArgumentNullException

The sourceFileName parameter is null.

ArgumentException

The mode is set to Create.