Table of Contents

Class SgaFolder

Namespace
OpenCompote.SGA
Assembly
OpenCompote.dll

Represents a folder within a SGA archive.

public class SgaFolder : SgaEntry
Inheritance
SgaFolder
Inherited Members

Properties

Contents

Gets the collection of entries that are currently in the current folder.

public IReadOnlyCollection<SgaEntry> Contents { get; }

Property Value

IReadOnlyCollection<SgaEntry>

Exceptions

ObjectDisposedException

This folder was deleted or the parent archive has been disposed.

Methods

AddFile(string, StorageType)

Created an empty SgaFile in the current folder.

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 SGA archive for this folder was open in readonly mode.

ObjectDisposedException

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

ArgumentException

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

ArgumentNullException

The name is null.

ArgumentOutOfRangeException

The type is invalid.

AddFolder(string)

Creates an empty SgaFolder with name in the current folder.

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

Exceptions

InvalidOperationException

The SGA archive for this folder was open in readonly mode.

ObjectDisposedException

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

ArgumentException

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

ArgumentNullException

The name is null.

ExtractToDirectory(string, bool)

Extracts this SgaFolder 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 SgaFolder 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 folder by its relative path or null when an entry for selected path did not exist.

public SgaEntry? GetEntry(string path)

Parameters

path string

Relative path to the entry.

Returns

SgaEntry

Found sgaEntry or null when entry with path does not exist.

Exceptions

ObjectDisposedException

This folder is deleted or the archive is disposed.

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