Class CpioArchive

Class CpioArchive

Tên không gian: Aspose.Zip.Cpio Tổng hợp: Aspose.Zip.dll (25.5.0)

Lớp này đại diện cho file cpio.

public class CpioArchive : IArchive, IDisposable

Inheritance

object CpioArchive

Implements

IArchive , IDisposable

Thành viên thừa kế

object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()

Constructors

CpioArchive()

Bắt đầu một trường hợp mới của lớp Aspose.Zip.Cpio.CpioArchive.

public CpioArchive()

Examples

Ví dụ sau đây cho thấy làm thế nào để nén một tệp.

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

CpioArchive(Stream)

Bắt đầu một ví dụ mới của lớp Aspose.Zip.Cpio.CpioArchive và tạo ra một danh sách nhập có thể được rút ra từ lưu trữ.

public CpioArchive(Stream sourceStream)

Parameters

sourceStream Stream

Nguồn gốc của tài liệu. nó phải được tìm kiếm.

Examples

Ví dụ sau đây cho thấy làm thế nào để rút tất cả các mục vào một thư mục.

using (var archive = new CpioArchive(File.OpenRead("archive.cpio")))
{ 
   archive.ExtractToDirectory("C:\extracted");
}

Remarks

Nhà sản xuất này không đóng gói bất kỳ đầu vào. Xem Aspose.Zip.Cpio.CpioEntry.Open phương pháp để đóng gói.

Exceptions

ArgumentNullException

sourceStream’ is null.

ArgumentException

sourceStream’ is not seekable.

InvalidDataException

sourceStream’ is not valid cpio archive.

CpioArchive(String)

Bắt đầu một ví dụ mới của lớp Aspose.Zip.Cpio.CpioArchive và tạo ra một danh sách nhập có thể được rút ra từ lưu trữ.

public CpioArchive(string path)

Parameters

path string

Cách di chuyển đến file file.

Examples

Ví dụ sau đây cho thấy làm thế nào để rút tất cả các mục vào một thư mục.

using (var archive = new CpioArchive("archive.cpio")) 
{ 
   archive.ExtractToDirectory("C:\extracted");
}

Remarks

Nhà sản xuất này không đóng gói bất kỳ đầu vào. Xem Aspose.Zip.Cpio.CpioEntry.Open phương pháp để đóng gói.

Exceptions

ArgumentNullException

path’ is null.

SecurityException

Người gọi không có giấy phép cần thiết để truy cập.

ArgumentException

Đường path’ là trống, chỉ chứa các không gian trắng, hoặc chứa các ký tự vô hiệu.

UnauthorizedAccessException

Truy cập vào tệp path" bị từ chối.

PathTooLongException

Lối đi path", tên tệp, hoặc cả hai vượt quá chiều dài tối đa được xác định bởi hệ thống. Ví dụ, trên nền tảng dựa trên Windows, các con đường phải nhỏ hơn 248 ký tự, và tên tệp phải nhỏ hơn 260 ký tự.

NotSupportedException

Tệp ở path’ chứa một cột (:) ở giữa dòng.

FileNotFoundException

file không được tìm thấy.

DirectoryNotFoundException

Con đường được chỉ định là vô hiệu, chẳng hạn như ở trên một ổ đĩa không được vẽ.

IOException

Tệp đã mở rồi.

Properties

Entries

Gets entries of Aspose.Zip.Cpio.CpioEntry type constituting the archive.

public ReadOnlyCollection<cpioentry> Entries { get; }

Giá trị bất động sản

ReadOnlyCollection < CpioEntry >

Methods

CreateEntries(Lời bài hát: Bool)

Thêm vào lưu trữ tất cả các tập tin và thư mục lặp lại trong thư mục được cung cấp.

public CpioArchive CreateEntries(string sourceDirectory, bool includeRootDirectory = true)

Parameters

sourceDirectory string

Hướng dẫn làm compress.

includeRootDirectory bool

Nó chỉ ra liệu phải bao gồm bản địa gốc hay không.

Returns

CpioArchive

Cpio nhập cảnh.

Examples

using (FileStream cpioFile = File.Open("archive.cpio", FileMode.Create))
{
    using (var archive = new CpioArchive())
    {
        archive.CreateEntries("C:\folder", false);
        archive.Save(cpioFile);
    }
}

Exceptions

ArgumentNullException

sourceDirectory’ is null.

SecurityException

Người gọi không có giấy phép cần thiết để truy cập sourceDirectory'.

ArgumentException

sourceDirectory’ contains invalid characters such as “, <, >, or |.

PathTooLongException

Đường được chỉ định, tên tệp, hoặc cả hai vượt quá chiều dài tối đa được xác định bởi hệ thống. Ví dụ, trên nền tảng dựa trên Windows, đường phải nhỏ hơn 248 ký tự, và tên tệp phải nhỏ hơn 260 ký tự. đường được chỉ định, tên tệp, hoặc cả hai quá dài.

IOException

sourceDirectory’ stands for a file, not for a directory.

CreateEntries(Bảng tin tức, bool)

Thêm vào lưu trữ tất cả các tập tin và thư mục lặp lại trong thư mục được cung cấp.

public CpioArchive CreateEntries(DirectoryInfo directory, bool includeRootDirectory = true)

Parameters

directory DirectoryInfo

Hướng dẫn làm compress.

includeRootDirectory bool

Nó chỉ ra liệu phải bao gồm bản địa gốc hay không.

Returns

CpioArchive

Cpio nhập cảnh.

Examples

using (FileStream cpioFile = File.Open("archive.cpio", FileMode.Create))
{
    using (var archive = new CpioArchive())
    {
        archive.CreateEntries(new DirectoryInfo("C:\folder"), false);
        archive.Save(cpioFile);
    }
}

Exceptions

ArgumentNullException

directory’ is null.

SecurityException

Người gọi không có quyền cần thiết để truy cập directory”.

IOException

directory’ stands for a file, not for a directory.

CreateEntry(Nhãn hiệu: FileInfo, Bool)

Tạo một bản ghi duy nhất trong hồ sơ.

public CpioEntry CreateEntry(string name, FileInfo fileInfo, bool openImmediately = false)

Parameters

name string

Tên của entry.

fileInfo FileInfo

Các metadata của tệp hoặc thư mục để được nén.

openImmediately bool

Thật vậy, nếu bạn mở tệp ngay lập tức, nếu không mở tệp trên lưu trữ.

Returns

CpioEntry

Cpio nhập cảnh.

Examples

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

Remarks

Nếu tệp được mở ngay lập tức với thông số, nó sẽ bị chặn cho đến khi lưu trữ bị xóa.

Exceptions

ArgumentNullException

name’ is null.

ArgumentException

name’ is empty.

ArgumentNullException

fileInfo’ is null.

CreateEntry(string, string, bool)

Tạo một bản ghi duy nhất trong hồ sơ.

public CpioEntry CreateEntry(string name, string sourcePath, bool openImmediately = false)

Parameters

name string

Tên của entry.

sourcePath string

Cách để file để được nén.

openImmediately bool

Thật vậy, nếu bạn mở tệp ngay lập tức, nếu không mở tệp trên lưu trữ.

Returns

CpioEntry

Cpio nhập cảnh.

Examples

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

Remarks

Tên đăng nhập chỉ được đặt trong parameter. tên tệp được cung cấp trong parameter không ảnh hưởng đến tên đăng nhập.

Nếu tệp được mở ngay lập tức với thông số, nó sẽ bị chặn cho đến khi lưu trữ bị xóa.

Exceptions

ArgumentNullException

sourcePath’ is null.

SecurityException

Người gọi không có giấy phép cần thiết để truy cập.

ArgumentException

sourcePath’ là trống, chỉ chứa không gian trắng, hoặc chứa các ký tự bất hợp lệ. - hoặc - Tên tập tin, như một phần của name’, vượt quá 100 ký tự.

UnauthorizedAccessException

Truy cập vào tệp sourcePath’ bị từ chối.

PathTooLongException

Ví dụ, trên các nền tảng dựa trên Windows, các con đường phải nhỏ hơn 248 ký tự và tên tập tin phải nhỏ hơn 260 ký tự. - hoặc - name’ là quá dài cho cpio.

NotSupportedException

Tệp ở sourcePath’ chứa một cột (:) ở giữa dòng.

CreateEntry(Stream , Stream)

Tạo một bản ghi duy nhất trong hồ sơ.

public CpioEntry CreateEntry(string name, Stream source)

Parameters

name string

Tên của entry.

source Stream

dòng đầu vào cho đầu vào.

Returns

CpioEntry

Cpio nhập cảnh.

Examples

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

Exceptions

ArgumentNullException

name’ is null.

ArgumentNullException

source’ is null.

ArgumentException

name’ is empty.

DeleteEntry(CpioEntry)

Xóa sự xuất hiện đầu tiên của một bài đăng cụ thể từ danh sách bài đăng.

public CpioArchive DeleteEntry(CpioEntry entry)

Parameters

entry CpioEntry

Đăng nhập để loại bỏ khỏi danh sách đăng nhập.

Returns

CpioArchive

Cpio nhập cảnh.

Examples

Dưới đây là cách bạn có thể xóa tất cả các bài đăng ngoại trừ bài đăng cuối cùng:

using (var archive = new CpioArchive("archive.cpio"))
{
    while (archive.Entries.Count &gt; 1)
        archive.DeleteEntry(archive.Entries[0]);
    archive.Save(outputCpioFile);
}

Exceptions

ArgumentNullException

entry’ is null.

DeleteEntry(int)

Xóa nhập từ danh sách nhập theo chỉ số.

public CpioArchive DeleteEntry(int entryIndex)

Parameters

entryIndex int

Chỉ số dựa trên zero của nhập để loại bỏ.

Returns

CpioArchive

Archive with entry đã bị xóa.

Examples

using (var archive = new CpioArchive("two_files.cpio"))
{
    archive.DeleteEntry(0);
    archive.Save("single_file.cpio");
}

Exceptions

ArgumentOutOfRangeException

entryIndex’ is less than 0.-or- entryIndex’ is equal to or greater than ‘Entries’ count.

Dispose()

Thực hiện các nhiệm vụ được xác định theo ứng dụng liên quan đến việc giải phóng, giải phóng hoặc tái quản lý các tài nguyên không được quản lý.

public void Dispose()

Dispose(Bool)

Thực hiện các nhiệm vụ được xác định theo ứng dụng liên quan đến việc giải phóng, giải phóng hoặc tái quản lý các tài nguyên không được quản lý.

protected virtual void Dispose(bool disposing)

Parameters

disposing bool

Liệu các tài nguyên được quản lý có nên được khai thác hay không.

ExtractToDirectory(String)

Loại bỏ tất cả các tập tin trong tập tin vào thư mục được cung cấp.

public void ExtractToDirectory(string destinationDirectory)

Parameters

destinationDirectory string

Con đường đến thư mục để đặt các tập tin được lấy vào.

Examples

using (var archive = new CpioArchive("archive.cpio")) 
{ 
   archive.ExtractToDirectory("C:\extracted");
}

Remarks

Nếu thư mục không tồn tại, nó sẽ được tạo ra.

Exceptions

ArgumentNullException

Con đường là zero

PathTooLongException

Các con đường cụ thể, tên tệp hoặc cả hai đều vượt quá chiều dài tối đa được xác định bởi hệ thống. Ví dụ, trên nền tảng dựa trên Windows, con đường phải nhỏ hơn 248 ký tự và tên tệp phải nhỏ hơn 260 ký tự.

SecurityException

Người gọi không có giấy phép cần thiết để truy cập thư mục hiện có.

NotSupportedException

Nếu thư mục không tồn tại, một con đường chứa một ký tự vỏ (:) không phải là một phần của một nhãn ổ đĩa (“C:”).

ArgumentException

Con đường là một dòng dài không, chỉ chứa không gian trắng, hoặc chứa một hoặc nhiều ký tự không có hiệu lực. Bạn có thể truy vấn cho ký tự không có hiệu lực bằng cách sử dụng phương pháp System.IO.Path.GetInvalidPathChars. -or- con đường được đặt trước với, hoặc chứa, chỉ có một ký tự cột (:).

IOException

Danh mục được chỉ định theo con đường là một tệp. -or- Tên mạng không được biết.

Save(Màn hình, CpioFormat)

Tiết kiệm lưu trữ đến một tập tin đích được cung cấp.

public void Save(string destinationFileName, CpioFormat cpioFormat = CpioFormat.OldAscii)

Parameters

destinationFileName string

Nếu tên tệp được chỉ định cho một tệp hiện có, nó sẽ được viết quá.

cpioFormat CpioFormat

Định dạng cpio header.

Examples

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

Remarks

Nó có thể được lưu trữ một tập tin theo cùng một con đường như nó đã được tải về từ. tuy nhiên, điều này không được khuyến khích bởi vì phương pháp này sử dụng sao chép vào một tập tin tạm thời.

Exceptions

ArgumentException

destinationFileName’ is a zero-length string, contains only white space, or contains one or more invalid characters as defined by System.IO.Path.InvalidPathChars.

ArgumentNullException

destinationFileName’ is null.

PathTooLongException

Mục đích destinationFileName’, tên tệp, hoặc cả hai vượt quá chiều dài tối đa được xác định bởi hệ thống. Ví dụ, trên nền tảng dựa trên Windows, con đường phải nhỏ hơn 248 ký tự, và tên tệp phải nhỏ hơn 260 ký tự.

DirectoryNotFoundException

Mục định destinationFileName’ là vô hiệu, (ví dụ, nó là trên một ổ đĩa không được vẽ).

IOException

Một lỗi I/O xảy ra trong khi mở tệp.

UnauthorizedAccessException

destinationFileName’Specified a file is read-only and access is not Read.-or- path specified a directory.-or- The caller does not have the required permission.

NotSupportedException

destinationFileName’ is in an invalid format.

Save(Thông tin, CpioFormat)

Tiết kiệm lưu trữ cho dòng cung cấp.

public void Save(Stream output, CpioFormat cpioFormat = CpioFormat.OldAscii)

Parameters

output Stream

Destination dòng

cpioFormat CpioFormat

Định dạng cpio header.

Examples

using (FileStream cpioFile = File.Open("archive.cpio", FileMode.Create))
{
    using (var archive = new CpioArchive())
    {
        archive.CreateEntry("entry1", "data.bin");        
        archive.Save(cpioFile);
    }
}

Remarks

phải có thể viết.

Exceptions

ArgumentNullException

output’ is null.

ArgumentException

output’ is not writable. - or - output’ is the same stream we extract from.- OR -It is impossible to save archive in cpioFormat’ due to format restrictions.

SaveGzipped(Thông tin, CpioFormat)

Tiết kiệm lưu trữ cho dòng với gzip compression.

public void SaveGzipped(Stream output, CpioFormat cpioFormat = CpioFormat.OldAscii)

Parameters

output Stream

Destination dòng

cpioFormat CpioFormat

Định dạng cpio header.

Examples

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

Remarks

phải có thể viết.

Exceptions

ArgumentNullException

output’ is null.

ArgumentException

output’ is not writable.

SaveGzipped(Màn hình, CpioFormat)

Tiết kiệm lưu trữ cho tệp theo con đường với gzip.

public void SaveGzipped(string path, CpioFormat cpioFormat = CpioFormat.OldAscii)

Parameters

path string

Nếu tên tệp được chỉ định cho một tệp hiện có, nó sẽ được viết quá.

cpioFormat CpioFormat

Định dạng cpio header.

Examples

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

SaveLZMACdập tắt(Thông tin, CpioFormat)

Tiết kiệm lưu trữ đến dòng với LZMA compression.

public void SaveLZMACompressed(Stream output, CpioFormat cpioFormat = CpioFormat.OldAscii)

Parameters

output Stream

Destination dòng

cpioFormat CpioFormat

Định dạng cpio header.

Examples

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

Remarks

phải có thể viết.

Quan trọng: cpio lưu trữ được thành lập sau đó được nén trong phương pháp này, nội dung của nó được lưu trữ nội bộ.

SaveLZMACdập tắt(Màn hình, CpioFormat)

Tiết kiệm lưu trữ đến tệp theo con đường với lzma compression.

public void SaveLZMACompressed(string path, CpioFormat cpioFormat = CpioFormat.OldAscii)

Parameters

path string

Nếu tên tệp được chỉ định cho một tệp hiện có, nó sẽ được viết quá.

cpioFormat CpioFormat

Định dạng cpio header.

Examples

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

Remarks

Quan trọng: cpio lưu trữ được thành lập sau đó được nén trong phương pháp này, nội dung của nó được lưu trữ nội bộ.

SaveLzipped(Thông tin, CpioFormat)

Tiết kiệm lưu trữ cho dòng với lzip compression.

public void SaveLzipped(Stream output, CpioFormat cpioFormat = CpioFormat.OldAscii)

Parameters

output Stream

Destination dòng

cpioFormat CpioFormat

Định dạng cpio header.

Examples

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

Remarks

phải có thể viết.

Exceptions

ArgumentNullException

output’ is null.

ArgumentException

output’ is not writable.

SaveLzipped(Màn hình, CpioFormat)

Tiết kiệm lưu trữ cho tệp theo con đường với lzip.

public void SaveLzipped(string path, CpioFormat cpioFormat = CpioFormat.OldAscii)

Parameters

path string

Nếu tên tệp được chỉ định cho một tệp hiện có, nó sẽ được viết quá.

cpioFormat CpioFormat

Định dạng cpio header.

Examples

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

SaveXzCompressed(Stream, CpioFormat, XzArchiveSettings)

Tiết kiệm lưu trữ cho dòng với xz compression.

public void SaveXzCompressed(Stream output, CpioFormat cpioFormat = CpioFormat.OldAscii, XzArchiveSettings settings = null)

Parameters

output Stream

Destination dòng

cpioFormat CpioFormat

Định dạng cpio header.

settings XzArchiveSettings

Set of setting particular xz archive: kích thước từ điển, kích thước khối, kiểm tra kiểu.

Examples

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

Remarks

dòng phải có khả năng viết.

Exceptions

ArgumentNullException

output’ is null.

ArgumentException

output’ is not writable.

SaveXzCompressed(Thẻ, CpioFormat, XzArchiveSettings)

Tiết kiệm lưu trữ cho con đường theo con đường với xz nén.

public void SaveXzCompressed(string path, CpioFormat cpioFormat = CpioFormat.OldAscii, XzArchiveSettings settings = null)

Parameters

path string

Nếu tên tệp được chỉ định cho một tệp hiện có, nó sẽ được viết quá.

cpioFormat CpioFormat

Định dạng cpio header.

settings XzArchiveSettings

Set of setting particular xz archive: kích thước từ điển, kích thước khối, kiểm tra kiểu.

Examples

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

SaveZCompressed(Thông tin, CpioFormat)

Tiết kiệm lưu trữ cho dòng bằng cách nén Z.

public void SaveZCompressed(Stream output, CpioFormat cpioFormat = CpioFormat.OldAscii)

Parameters

output Stream

Destination dòng

cpioFormat CpioFormat

Định dạng cpio header.

Examples

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

Remarks

phải có thể viết.

Exceptions

ArgumentNullException

output’ is null.

ArgumentException

output’ is not writable.

SaveZCompressed(Màn hình, CpioFormat)

Tiết kiệm lưu trữ cho con đường theo con đường với nén Z.

public void SaveZCompressed(string path, CpioFormat cpioFormat = CpioFormat.OldAscii)

Parameters

path string

Nếu tên tệp được chỉ định cho một tệp hiện có, nó sẽ được viết quá.

cpioFormat CpioFormat

Định dạng cpio header.

Examples

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

SaveZstandard(Thông tin, CpioFormat)

Tiết kiệm lưu trữ cho dòng với Zstandard compression.

public void SaveZstandard(Stream output, CpioFormat cpioFormat = CpioFormat.OldAscii)

Parameters

output Stream

Destination dòng

cpioFormat CpioFormat

Định dạng cpio header.

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);
        }
    }
}

Remarks

phải có thể viết.

Exceptions

ArgumentNullException

output’ is null.

ArgumentException

output’ is not writable.

SaveZstandard(Màn hình, CpioFormat)

Tiết kiệm lưu trữ cho tệp theo con đường với Zstandard compression.

public void SaveZstandard(string path, CpioFormat cpioFormat = CpioFormat.OldAscii)

Parameters

path string

Nếu tên tệp được chỉ định cho một tệp hiện có, nó sẽ được viết quá.

cpioFormat CpioFormat

Định dạng cpio header.

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");
    }
}
 Tiếng Việt