CreateEntry

CpioArchive.CreateEntry method (1 of 3)

Create single entry within the archive.

public CpioEntry CreateEntry(string name, FileInfo fileInfo, bool openImmediately = false)
ParameterTypeDescription
nameStringThe name of the entry.
fileInfoFileInfoThe metadata of file or folder to be compressed.
openImmediatelyBooleanTrue if open the file immediately, otherwise open the file on archive saving.

Return Value

Cpio entry instance.

Exceptions

exceptioncondition
ArgumentNullExceptionname is null.
ArgumentExceptionname is empty.
ArgumentNullExceptionfileInfo is null.

Remarks

If the file is opened immediately with openImmediately parameter it becomes blocked until archive is disposed.

Examples

FileInfo fileInfo = new FileInfo("data.bin");
using (var archive = new CpioArchive())
{
    archive.CreateEntry("test.bin", fileInfo);
    archive.Save("archive.cpio");
}

See Also


CpioArchive.CreateEntry method (2 of 3)

Create single entry within the archive.

public CpioEntry CreateEntry(string name, string sourcePath, bool openImmediately = false)
ParameterTypeDescription
nameStringThe name of the entry.
sourcePathStringPath to file to be compressed.
openImmediatelyBooleanTrue if open the file immediately, otherwise open the file on archive saving.

Return Value

Cpio entry instance.

Exceptions

exceptioncondition
ArgumentNullExceptionsourcePath is null.
SecurityExceptionThe caller does not have the required permission to access.
ArgumentExceptionThe sourcePath is empty, contains only white spaces, or contains invalid characters. - or - File name, as a part of name, exceeds 100 symbols.
UnauthorizedAccessExceptionAccess to file sourcePath is denied.
PathTooLongExceptionThe specified sourcePath, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. - or - name is too long for cpio.
NotSupportedExceptionFile at sourcePath contains a colon (:) in the middle of the string.

Remarks

The entry name is solely set within name parameter. The file name provided in sourcePath parameter does not affect the entry name.

If the file is opened immediately with openImmediately parameter it becomes blocked until archive is disposed.

Examples

using (var archive = new CpioArchive())
{
    archive.CreateEntry("first.bin", "data.bin");
    archive.Save("archive.cpio");
}

See Also


CpioArchive.CreateEntry method (3 of 3)

Create single entry within the archive.

public CpioEntry CreateEntry(string name, Stream source)
ParameterTypeDescription
nameStringThe name of the entry.
sourceStreamThe input stream for the entry.

Return Value

Cpio entry instance.

Exceptions

exceptioncondition
ArgumentNullExceptionname is null.
ArgumentNullExceptionsource is null.
ArgumentExceptionname is empty.

Examples

using (var archive = new CpioArchive())
{
    archive.CreateEntry("data.bin", File.OpenRead("data.bin"));
    archive.Save("archive.cpio");
}

See Also