Table of Contents

Class SgaDrive

Namespace
OpenCompote.SGA
Assembly
OpenCompote.dll

Represents a drive within a SGA archive.

public class SgaDrive
Inheritance
SgaDrive
Inherited Members

Properties

Alias

Gets or sets the alias of the drive. Alias must be 64 characters long or shorter. Longer input will be trimmed to 64 characters. Alias can be an empty string.

public string Alias { get; set; }

Property Value

string

Remarks

Alias cannot be null, but can be set to an empty string.

Exceptions

InvalidOperationException

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

ArgumentNullException

Setter throws this exception when the new value is null.

ObjectDisposedException

The parent archive was already closed, or this drive is deleted.

Archive

Gets the SGA archive that the drive belongs to.

public SgaArchive Archive { get; }

Property Value

SgaArchive

Exceptions

ObjectDisposedException

The drive is deleted or parent archive was closed(disposed).

Contents

Gets the collection of entries that are currently in this drive.

public IReadOnlyCollection<SgaEntry> Contents { get; }

Property Value

IReadOnlyCollection<SgaEntry>

Exceptions

ObjectDisposedException

The parent archive was already closed, or this drive is deleted.

Name

Gets or sets the name of the drive. Name must contain only valid characters and must be 64 characters long or shorter. Longer names are trimmed to 64 characters. 2 drives with with the same name cannot exists in the archive.

public string Name { get; set; }

Property Value

string

Exceptions

InvalidOperationException

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

ArgumentException

Setter throws this exception when the new name is not valid drive name, or drive with this name already exists.

ArgumentNullException

Setter throws this exception when the new name value is null.

ObjectDisposedException

The parent archive was already closed, or this drive is deleted.

Methods

AddFile(string, StorageType)

Creates an empty SgaFile in this drive.

public SgaFile AddFile(string name, StorageType type)

Parameters

name string

The name of the new file. File name must be a valid sga name. for more info see File/Folder naming restrictions.

type StorageType

The storage type of the new file.

Returns

SgaFile

New empty file.

Exceptions

InvalidOperationException

The parent SGA archive was open in readonly mode.

ObjectDisposedException

The parent SGA archive has been disposed, or drive is deleted.

ArgumentException

The name is not a valid sga file name, or entry with this name already exists in this drive.

ArgumentNullException

The name is null.

ArgumentOutOfRangeException

The type is invalid.

AddFolder(string)

Creates an empty SgaFolder with name in the this drive.

public SgaFolder AddFolder(string name)

Parameters

name string

The name of the folder to be created. Folder name must be a valid sga name. for more info see File/Folder naming restrictions.

Returns

SgaFolder

New empty folder.

Exceptions

InvalidOperationException

The parent SGA archive was open in readonly mode.

ObjectDisposedException

The parent SGA archive has been disposed, or this drive is deleted.

ArgumentException

The name is not a valid sga entry name, or entry with this name already exists in this drive.

ArgumentNullException

The name is null.

Delete()

Deletes the drive and all its contents from the archive.

public void Delete()

Remarks

Deleting already deleted drive again throws the ObjectDisposedException.

Exceptions

InvalidOperationException

The parent SgaArchive was open in readonly mode.

ObjectDisposedException

The parent SgaArchive has already been closed, or this drive is deleted.

ExtractToDirectory(string, bool)

Extracts this SgaDrive and its contents to a subdirectory named after the folder in the parentFolder.

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

Parameters

parentFolder string

The path to the parent directory to which SgaDrive 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.

Exceptions

ArgumentException

parentFolder is invalid path, empty or whitespace.

ArgumentNullException

parentFolder is null

ObjectDisposedException

The SGA archive for this folder has been disposed, or this folder is deleted.

IOException

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

-OR-

Other IOException occurs, for more potential exceptions see CreateDirectory(string) and Open(string, FileMode) methods.

InvalidOperationException

Archive SgaMode value is invalid.

GetEntry(string)

Finds an existing entry inside of this drive by its relative path or null when an entry for selected path does not exist.

public SgaEntry? GetEntry(string path)

Parameters

path string

Relative path to the entry.

Returns

SgaEntry

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

Exceptions

ObjectDisposedException

The parent SGA archive has been disposed, or drive is deleted.

ArgumentException

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

ArgumentNullException

path is null.

ImportFromDirectory(string, StorageType)

Imports the specified directory and its contents into this drive as a new subfolder. Subdirectories are imported recursively, and imported files use defaultType as their storage type.

public SgaFolder ImportFromDirectory(string dirPath, StorageType defaultType)

Parameters

dirPath string

The path to the directory to import.

defaultType StorageType

The default storage type for imported files.

Returns

SgaFolder

New SgaFolder containing the imported directory contents.

Remarks

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 error occurs during import, entries already added to the archive 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 folder is deleted or its parent archive was disposed.

InvalidOperationException

The archive is open in read-only mode.

IOException

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

ImportFromFile(string, StorageType)

Creates a new SgaFile and fill it with the contents of the file with filePath.

public SgaFile ImportFromFile(string filePath, StorageType type)

Parameters

filePath string

File path to the file we want to import.

type StorageType

Storage type that we want to use.

Returns

SgaFile

New sgaFile with contents