CpioArchive.SaveZstandard

SaveZstandard(Stream, CpioFormat)

Saves archive to the stream with Zstandard compression.

public void SaveZstandard(Stream output, CpioFormat cpioFormat = CpioFormat.OldAscii)
ParameterTypeDescription
outputStreamDestination stream.
cpioFormatCpioFormatDefines cpio header format.

Exceptions

exceptioncondition
ArgumentNullExceptionoutput is null.
ArgumentExceptionoutput is not writable.
ObjectDisposedExceptionArchive has been disposed and cannot be used.

Remarks

output must be writable.

Examples

using (FileStream result = File.OpenWrite("result.cpio.zst"))
{
    using (FileStream source = File.Open("data.bin", FileMode.Open, FileAccess.Read))
    {
        using (var archive = new CpioArchive())
        {
            archive.CreateEntry("entry.bin", source);
            archive.SaveZstandard(result);
        }
    }
}

See Also


SaveZstandard(string, CpioFormat)

Saves archive to the file by path with Zstandard compression.

public void SaveZstandard(string path, CpioFormat cpioFormat = CpioFormat.OldAscii)
ParameterTypeDescription
pathStringThe path of the archive to be created. If the specified file name points to an existing file, it will be overwritten.
cpioFormatCpioFormatDefines cpio header format.

Exceptions

exceptioncondition
ObjectDisposedExceptionArchive has been disposed and cannot be used.
ArgumentExceptionpath is a zero-length string, contains only white space, or contains one or more invalid characters as defined by InvalidPathChars.
ArgumentNullExceptionpath is null.
DirectoryNotFoundExceptionThe specified path is invalid, (for example, it is on an unmapped drive).
IOExceptionAn I/O error occurs.
PathTooLongExceptionThe specified path, file name, or both exceed the system-defined maximum length.
UnauthorizedAccessExceptionThe caller does not have the required permission. -or- path specified a read-only file or directory.

Examples

using (FileStream source = File.Open("data.bin", FileMode.Open, FileAccess.Read))
{
    using (var archive = new CpioArchive())
    {
        archive.CreateEntry("entry.bin", source);
        archive.SaveZstandard("result.cpio.zst");
    }
}

See Also