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
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
Exceptions
- ObjectDisposedException
The archive was already closed.
Mode
Gets the Mode in which the archive was opened.
public SgaMode Mode { get; }
Property Value
Exceptions
- ObjectDisposedException
The archive was already closed.
Version
Gets the version of the SGA archive.
public SgaVersion Version { get; }
Property Value
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
Returns
- SgaDrive
New SgaDrive object
Exceptions
- InvalidOperationException
Archive was open in read-only mode.
- ArgumentNullException
aliasornameis 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
destinationFolderstringThe path to the directory to which the archive 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.
Remarks
When exporting drives the drive name is used as the name of the exported directory.
Exceptions
- ArgumentException
destinationFolderis invalid path, empty or whitespace.- ArgumentNullException
destinationFolderis 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
Returns
Exceptions
- ArgumentNullException
The
driveNameis 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
pathstringAbsolute path of the entry.
Returns
Exceptions
- ObjectDisposedException
The SGA archive has been disposed.
- ArgumentException
pathis empty string or will be after trimming separators and whitespaces.- ArgumentNullException
pathis 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
dirPathstringThe path to the directory that will be imported.
defaultTypeStorageTypeThe default storage type for imported files.
Returns
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
dirPathis empty or whitespace, or the directory name is invalid or conflicts with an existing entry.- ArgumentNullException
dirPathis 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.