Table of Contents

Class SgaArchive

Namespace
OpenCompote.SGA
Assembly
OpenCompote.dll

Represents the open SGA archive file itself.

public class SgaArchive : IDisposable
Inheritance
SgaArchive
Implements
Inherited Members

Properties

ArchiveName

Gets or sets the name of the SGA archive.

public string ArchiveName { get; set; }

Property Value

string

Exceptions

InvalidOperationException

Setter throws this exception when the archive was opened in read-only mode.

ObjectDisposedException

The archive was already closed.

Drives

Gets the collection of SGA Drives currently in the archive.

public IReadOnlyCollection<SgaDrive> Drives { get; }

Property Value

IReadOnlyCollection<SgaDrive>

Exceptions

ObjectDisposedException

The archive was already closed.

Mode

Gets the Mode in which the archive was opened.

public SgaMode Mode { get; }

Property Value

SgaMode

Exceptions

ObjectDisposedException

The archive was already closed.

Version

Gets the version of the SGA archive.

public SgaVersion Version { get; }

Property Value

SgaVersion

Exceptions

ObjectDisposedException

The archive was already closed.

Methods

AddDrive(string, string)

Creates new SgaDrive in the archive with the specified alias and name.

public SgaDrive AddDrive(string alias, string name)

Parameters

alias string

Alias of the new drive.

name string

Name of the new drive.

Returns

SgaDrive

New SgaDrive object

Exceptions

InvalidOperationException

Archive was open in read-only mode.

ArgumentNullException

alias or name is null.

ObjectDisposedException

The archive was already closed.

Dispose()

Disposes the SGA archive, writing any pending changes if in create or write mode.

public void Dispose()

ExtractToDirectory(string, bool)

Extracts All archive Drives to a directory specified by destinationFolder.

public void ExtractToDirectory(string destinationFolder, bool overwrite = false)

Parameters

destinationFolder string

The path to the directory to which the archive will be exported.

overwrite bool

If the value is true, it overwrites existing files. Else, it throws an exception if a file with the same name already exists.

Remarks

When exporting drives the drive name is used as the name of the exported directory.

Exceptions

ArgumentException

destinationFolder is invalid path, empty or whitespace.

ArgumentNullException

destinationFolder is null

ObjectDisposedException

Archive is disposed.

IOException

One of the SgaFile in the archive is currently open for writing and cannot be exported.

-OR-

Other IOException occurred, for more info about potential source of the exception see CreateDirectory(string) and Open(string, FileMode) methods.

InvalidOperationException

Archive SgaMode value is invalid.

GetDrive(string)

Returns first SgaDrive with name or alias matching the parameter. If no matching drive is found returns null.

public SgaDrive? GetDrive(string driveName)

Parameters

driveName string

Name or Alias of the Drive.

Returns

SgaDrive

SgaDrive or null if no matching drive was found.

Exceptions

ArgumentNullException

The driveName is null.

ObjectDisposedException

The archive was already closed.

GetEntry(string)

Gets an existing entry inside of this archive by its absolute path or null when an entry with specified path does not exist.

public SgaEntry? GetEntry(string path)

Parameters

path string

Absolute path of the entry.

Returns

SgaEntry

Existing SgaEntry or null when entry with path does not exist.

Exceptions

ObjectDisposedException

The SGA archive has been disposed.

ArgumentException

path is empty string or will be after trimming separators and whitespaces.

ArgumentNullException

path is null.

ImportDriveFromDirectory(string, StorageType)

Imports the specified directory and its contents into this archive as a new SgaDrive. Subdirectories are imported recursively as folders and files inside the new drive. Imported files will use defaultType as their StorageType.

public SgaDrive ImportDriveFromDirectory(string dirPath, StorageType defaultType)

Parameters

dirPath string

The path to the directory that will be imported.

defaultType StorageType

The default storage type for imported files.

Returns

SgaDrive

New SgaDrive containing the imported directory contents.

Remarks

Both the Name and Alias of the new drive are set to the name of the dirPath folder.

Subdirectories are imported recursively, and all imported files use defaultType.

Symbolic links and other ReparsePoint are skipped. Special filesystem entries, such as named pipes, may fail to import or lock up while being read.

If an exception occurs during the import, entries already imported to the archive before the exception are not rolled back.

Exceptions

ArgumentException

dirPath is empty or whitespace, or the directory name is invalid or conflicts with an existing entry.

ArgumentNullException

dirPath is null.

ObjectDisposedException

This archive is disposed.

InvalidOperationException

This archive is open in read-only mode.

IOException

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