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
Implements
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
sourceStream’ is null.
sourceStream’ is not seekable.
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
path’ is null.
Người gọi không có giấy phép cần thiết để truy cập.
Đườ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.
Truy cập vào tệp path" bị từ chối.
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ự.
Tệp ở path’ chứa một cột (:) ở giữa dòng.
file không được tìm thấy.
Con đường được chỉ định là vô hiệu, chẳng hạn như ở trên một ổ đĩa không được vẽ.
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
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
sourceDirectory’ is null.
Người gọi không có giấy phép cần thiết để truy cập sourceDirectory'.
sourceDirectory’ contains invalid characters such as “, <, >, or |.
Đườ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.
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
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
directory’ is null.
Người gọi không có quyền cần thiết để truy cập directory”.
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
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
name’ is null.
name’ is empty.
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
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
sourcePath’ is null.
Người gọi không có giấy phép cần thiết để truy cập.
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ự.
Truy cập vào tệp sourcePath’ bị từ chối.
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.
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
Cpio nhập cảnh.
Examples
using (var archive = new CpioArchive())
{
archive.CreateEntry("data.bin", File.OpenRead("data.bin"));
archive.Save("archive.cpio");
}
Exceptions
name’ is null.
source’ is null.
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
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 > 1)
archive.DeleteEntry(archive.Entries[0]);
archive.Save(outputCpioFile);
}
Exceptions
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
Archive with entry đã bị xóa.
Examples
using (var archive = new CpioArchive("two_files.cpio"))
{
archive.DeleteEntry(0);
archive.Save("single_file.cpio");
}
Exceptions
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
Con đường là zero
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ự.
Người gọi không có giấy phép cần thiết để truy cập thư mục hiện có.
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:”).
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 (:).
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
destinationFileName’ is a zero-length string, contains only white space, or contains one or more invalid characters as defined by System.IO.Path.InvalidPathChars.
destinationFileName’ is null.
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ự.
Mục định destinationFileName’ là vô hiệu, (ví dụ, nó là trên một ổ đĩa không được vẽ).
Một lỗi I/O xảy ra trong khi mở tệp.
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.
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
output’ is null.
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
output’ is null.
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
output’ is null.
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
output’ is null.
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
output’ is null.
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
output’ is null.
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");
}
}