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
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
namestringThe name of the new file. File name must be a valid sga name. for more info see File/Folder naming restrictions.
typeStorageTypeThe 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
nameis not a valid sga file name, or entry with this name already exists in this folder.- ArgumentNullException
The
nameis null.- ArgumentOutOfRangeException
The
typeis invalid.
AddFolder(string)
Creates an empty SgaFolder with name in the current folder.
public SgaFolder AddFolder(string name)
Parameters
namestringThe 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
nameis not a valid sga entry name, or entry with this name already exists in this folder.- ArgumentNullException
The
nameis 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
parentFolderstringThe path to the parent directory to which SgaFolder will be exported.
overwriteboolIf the value is true, it overwrites existing files. Else, it throws an exception if a file with the same name already exists.
Exceptions
- ArgumentException
parentFolderis invalid path, empty or whitespace.- ArgumentNullException
parentFolderis 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
pathstringRelative path to the entry.
Returns
- SgaEntry
Found sgaEntry or null when entry with
pathdoes not exist.
Exceptions
- ObjectDisposedException
This folder is deleted or the archive is disposed.
- ArgumentException
pathis empty string or will be after trimming separators and whitespaces.- ArgumentNullException
pathis 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
dirPathstringThe path to the directory to import.
defaultTypeStorageTypeThe default storage type for imported files.
Returns
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
dirPathis empty or whitespace, or the directory name is invalid or conflicts with an existing entry.- ArgumentNullException
dirPathis 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
filePathstringFile path to the file we want to import.
typeStorageTypeStorage type that we want to use.
Returns
- SgaFile
New sgaFile with contents