Class CpioArchive
اسم الفضاء : Aspose.Zip.Cpio تجميع: Aspose.Zip.dll (25.5.0)
هذه الفئة تمثل ملف أرشيف cpio.
public class CpioArchive : IArchive, IDisposable
Inheritance
Implements
الأعضاء الموروثين
object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()
Constructors
CpioArchive()
يبدأ حالة جديدة من فئة Aspose.Zip.Cpio.CpioArchive.
public CpioArchive()
Examples
يظهر المثال التالي كيفية ضغط ملف.
using (var archive = new CpioArchive())
{
archive.CreateEntry("first.bin", "data.bin");
archive.Save("archive.cpio");
}
CpioArchive(Stream)
يبدأ مثالًا جديدًا من فئة Aspose.Zip.Cpio.CpioArchive ويجمع قائمة إدخال يمكن استخراجها من الأرشيف.
public CpioArchive(Stream sourceStream)
Parameters
sourceStream
Stream
مصدر الأرشيف يجب أن يكون قابلًا للبحث.
Examples
يظهر المثال التالي كيفية استخراج جميع الإدخالات إلى دليل.
using (var archive = new CpioArchive(File.OpenRead("archive.cpio")))
{
archive.ExtractToDirectory("C:\extracted");
}
Remarks
هذا المصنع لا يقطع أي إدخال. انظر Aspose.Zip.Cpio.CpioEntry.Open طريقة لقطع.
Exceptions
sourceStream’ is null.
sourceStream’ is not seekable.
sourceStream’ is not valid cpio archive.
CpioArchive(الستار)
يبدأ مثالًا جديدًا من فئة Aspose.Zip.Cpio.CpioArchive ويجمع قائمة إدخال يمكن استخراجها من الأرشيف.
public CpioArchive(string path)
Parameters
path
string
الطريق إلى ملف الأرشيف.
Examples
يظهر المثال التالي كيفية استخراج جميع الإدخالات إلى دليل.
using (var archive = new CpioArchive("archive.cpio"))
{
archive.ExtractToDirectory("C:\extracted");
}
Remarks
هذا المصنع لا يقطع أي إدخال. انظر Aspose.Zip.Cpio.CpioEntry.Open طريقة لقطع.
Exceptions
path’ is null.
لا يحصل المتصل على إذن الوصول المطلوب.
الطريق " فارغ ، يحتوي على مساحات بيضاء فقط ، أو يحتوي على أحرف غير صحيحة.
يتم رفض الوصول إلى ملف path".
على سبيل المثال ، على المنصات المستندة إلى Windows ، يجب أن تكون المسارات أقل من 248 حرفًا ، ويجب أن يكون اسم الملف أقل من 260 حرفًا.
ملف في path’ يحتوي على عمود (:) في وسط السلسلة.
لم يتم العثور على الملف.
المسار المحدد غير صالح ، على سبيل المثال ، على محرك أقراص غير مسجلة.
الملف مفتوح بالفعل.
Properties
Entries
يحصل على إدخالات من Aspose.Zip.Cpio.CpioEntry النوع الذي يشكل الأرشيف.
public ReadOnlyCollection<cpioentry> Entries { get; }
قيمة الممتلكات
ReadOnlyCollection <؛ CpioEntry >
Methods
CreateEntries(البول، البول)
إضافة إلى الأرشيف جميع الملفات والمجلدات مرارا وتكرارا في الدليل المحدد.
public CpioArchive CreateEntries(string sourceDirectory, bool includeRootDirectory = true)
Parameters
sourceDirectory
string
فيديوهات متعلقة بـ Compress
includeRootDirectory
bool
إشارة إلى ما إذا كان لإدراج الدليل الجذر نفسه أم لا.
Returns
إدخال Cpio instance.
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.
لا يتمتع المكالمة بالترخيص المطلوب للوصول إلى sourceDirectory'.
sourceDirectory’ contains invalid characters such as “, <, >, or |.
المسار المحدد، اسم الملف، أو كلاهما يتجاوز الحد الأقصى المحدد النظام. على سبيل المثال، على منصات ويندوز، يجب أن تكون المسارات أقل من 248 حرف، وأسماء الملفات يجب أن تكون أقل من 260 حرف.
sourceDirectory’ stands for a file, not for a directory.
CreateEntries(أرشيف الوسم : Bool)
إضافة إلى الأرشيف جميع الملفات والمجلدات مرارا وتكرارا في الدليل المحدد.
public CpioArchive CreateEntries(DirectoryInfo directory, bool includeRootDirectory = true)
Parameters
directory
DirectoryInfo
فيديوهات متعلقة بـ Compress
includeRootDirectory
bool
إشارة إلى ما إذا كان لإدراج الدليل الجذر نفسه أم لا.
Returns
إدخال Cpio instance.
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.
لا يحصل المتصل على السماح المطلوب للوصول إلى directory”.
directory’ stands for a file, not for a directory.
CreateEntry(أرشيف الوسم : FileInfo, Bool)
إنشاء إدخال واحد داخل الأرشيف.
public CpioEntry CreateEntry(string name, FileInfo fileInfo, bool openImmediately = false)
Parameters
name
string
اسم الدخول .
fileInfo
FileInfo
سيتم ضغط البيانات الميتا من الملف أو المجلد.
openImmediately
bool
صحيح، إذا قمت بفتح الملف على الفور، وإلا فتح الملف على حفظ الأرشيف.
Returns
إدخال Cpio instance.
Examples
FileInfo fileInfo = new FileInfo("data.bin");
using (var archive = new CpioArchive())
{
archive.CreateEntry("test.bin", fileInfo);
archive.Save("archive.cpio");
}
Remarks
إذا تم فتح الملف على الفور مع المعيار فإنه يتم حظرها حتى يتم إزالة الأرشيف.
Exceptions
name’ is null.
name’ is empty.
fileInfo’ is null.
CreateEntry(قوس قزح، قوس قزح)
إنشاء إدخال واحد داخل الأرشيف.
public CpioEntry CreateEntry(string name, string sourcePath, bool openImmediately = false)
Parameters
name
string
اسم الدخول .
sourcePath
string
الطريق إلى التسجيل لتكون مضغوطة.
openImmediately
bool
صحيح، إذا قمت بفتح الملف على الفور، وإلا فتح الملف على حفظ الأرشيف.
Returns
إدخال Cpio instance.
Examples
using (var archive = new CpioArchive())
{
archive.CreateEntry("first.bin", "data.bin");
archive.Save("archive.cpio");
}
Remarks
يتم تعيين اسم الإدخال فقط داخل المعلم.لا يؤثر اسم الملف المقدمة في المعلم على اسم الإدخال.
إذا تم فتح الملف على الفور مع المعيار فإنه يتم حظرها حتى يتم إزالة الأرشيف.
Exceptions
sourcePath’ is null.
لا يحصل المتصل على إذن الوصول المطلوب.
فالمصدر sourcePath’ فارغ، يحتوي فقط على مساحات بيضاء، أو يحتوي على أحرف غير صحيحة. - أو - اسم الملف، كجزء من
name"، يتجاوز 100 رمز.
يتم رفض الوصول إلى ملف sourcePath'.
على سبيل المثال ، على المنصات المستندة إلى Windows ، يجب أن تكون المسارات أقل من 248 حرفًا ، ويجب أن تكون أسماء الملفات أقل من 260 حرفًا. - أو - name’ طويل جدًا لـ cpio.
ملف في sourcePath’ يحتوي على عمود (:) في وسط السلسلة.
CreateEntry(الشريط , Stream)
إنشاء إدخال واحد داخل الأرشيف.
public CpioEntry CreateEntry(string name, Stream source)
Parameters
name
string
اسم الدخول .
source
Stream
تدفق الدخول للمدخل.
Returns
إدخال Cpio instance.
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)
إزالة الحدث الأول من إدخال معين من قائمة الإدخال.
public CpioArchive DeleteEntry(CpioEntry entry)
Parameters
entry
CpioEntry
إدخال إزالة من قائمة الإدخالات.
Returns
إدخال Cpio instance.
Examples
إليك كيفية إزالة جميع الإدخالات باستثناء الأخير:
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(إنت)
إزالة الإدخال من قائمة الإدخال بواسطة المؤشر.
public CpioArchive DeleteEntry(int entryIndex)
Parameters
entryIndex
int
المؤشر القائم على الصفر من الدخول لإزالة.
Returns
تم حذف الأرشيف مع الإدخال.
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()
يمارس المهام المحددة في التطبيق المرتبطة بتفريغ أو إطلاق أو إعادة تدوير الموارد غير المعالجة.
public void Dispose()
Dispose(بول)
يمارس المهام المحددة في التطبيق المرتبطة بتفريغ أو إطلاق أو إعادة تدوير الموارد غير المعالجة.
protected virtual void Dispose(bool disposing)
Parameters
disposing
bool
هل ينبغي تخصيص الموارد التي يتم إدارةها؟
ExtractToDirectory(الستار)
استخراج جميع الملفات في الأرشيف إلى الدليل المقدمة.
public void ExtractToDirectory(string destinationDirectory)
Parameters
destinationDirectory
string
الطريق إلى الدليل لوضع الملفات المستخرجة في.
Examples
using (var archive = new CpioArchive("archive.cpio"))
{
archive.ExtractToDirectory("C:\extracted");
}
Remarks
إذا لم يكن الدليل موجودًا ، فسيتم إنشاؤه.
Exceptions
الطريق صفر
على سبيل المثال، على منصات ويندوز، يجب أن تكون المسارات أقل من 248 حرف، وأسماء الملفات يجب أن تكون أقل من 260 حرف.
لا يتمتع المكالمة بالترخيص المطلوب للوصول إلى الدليل الحالي.
إذا لم يكن الدليل موجودًا ، فإن المسار يحتوي على حرف العمود الفقري (:) الذي ليس جزءًا من علامة محرك الأقراص (“C:”).
المسار هو سلسلة صفر الطول، يحتوي فقط على مساحة بيضاء، أو يحتوي على شخصية واحدة أو أكثر غير مؤهلة.يمكنك الاستعلام عن شخصيات غير مؤهلة باستخدام طريقة System.IO.Path.GetInvalidPathChars. -أو- المسار محدد مسبقا مع، أو يحتوي، فقط حرف العمود الفقري (:).
المجلد المحدد بالطريق هو ملف. -أو- اسم الشبكة غير معروف.
Save(الكمبيوتر، CpioFormat)
حفظ الأرشيف إلى ملف الوجهة المقدمة.
public void Save(string destinationFileName, CpioFormat cpioFormat = CpioFormat.OldAscii)
Parameters
destinationFileName
string
إذا كان اسم الملف المحدد يشير إلى ملف موجود ، فسيتم إعادة كتابته.
cpioFormat
CpioFormat
تحديد شكل cpio header.
Examples
using (var archive = new CpioArchive())
{
archive.CreateEntry("entry1", "data.bin");
archive.Save("archive.cpio");
}
Remarks
من الممكن حفظ الأرشيف في نفس المسار الذي تم تحميله من. ومع ذلك، هذا لا ينصح لأن هذا النهج يستخدم نسخ إلى ملف مؤقت.
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.
المحدد destinationFileName، اسم الملف، أو كلاهما يتجاوز الحد الأقصى الذي يحدده النظام.على سبيل المثال، على منصات ويندوز، يجب أن تكون المسارات أقل من 248 حرفا، وأسماء الملفات يجب أن تكون أقل من 260 حرفا.
المحدد destinationFileName’ غير صالح، (على سبيل المثال، هو على محرك أقراص غير مسجلة).
حدث خطأ I/O أثناء فتح الملف.
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(الشبكة، CpioFormat)
حفظ الأرشيف إلى التدفق المقدم.
public void Save(Stream output, CpioFormat cpioFormat = CpioFormat.OldAscii)
Parameters
output
Stream
النطاق المستهدف
cpioFormat
CpioFormat
تحديد شكل 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
يجب أن تكون مكتوبة.
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(الشبكة، CpioFormat)
توفير الأرشيف إلى التدفق باستخدام ضغط gzip.
public void SaveGzipped(Stream output, CpioFormat cpioFormat = CpioFormat.OldAscii)
Parameters
output
Stream
النطاق المستهدف
cpioFormat
CpioFormat
تحديد شكل 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
يجب أن تكون مكتوبة.
Exceptions
output’ is null.
output’ is not writable.
SaveGzipped(الكمبيوتر، CpioFormat)
حفظ الأرشيف إلى الملف عن طريق الطريق مع ضغط gzip.
public void SaveGzipped(string path, CpioFormat cpioFormat = CpioFormat.OldAscii)
Parameters
path
string
إذا كان اسم الملف المحدد يشير إلى ملف موجود ، فسيتم إعادة كتابته.
cpioFormat
CpioFormat
تحديد شكل 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");
}
}
التخزين المضغوط(الشبكة، CpioFormat)
حفظ الأرشيف إلى التدفق باستخدام ضغط LZMA.
public void SaveLZMACompressed(Stream output, CpioFormat cpioFormat = CpioFormat.OldAscii)
Parameters
output
Stream
النطاق المستهدف
cpioFormat
CpioFormat
تحديد شكل 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
يجب أن تكون مكتوبة.
مهم: يتم تجميع أرشيف cpio ثم يتم ضغطها داخل هذه الطريقة ، يتم الاحتفاظ بمحتواه داخليًا.
التخزين المضغوط(الكمبيوتر، CpioFormat)
تخزين الأرشيف إلى الملف عن طريق الطريق مع ضغط lzma.
public void SaveLZMACompressed(string path, CpioFormat cpioFormat = CpioFormat.OldAscii)
Parameters
path
string
إذا كان اسم الملف المحدد يشير إلى ملف موجود ، فسيتم إعادة كتابته.
cpioFormat
CpioFormat
تحديد شكل 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
مهم: يتم تجميع أرشيف cpio ثم يتم ضغطها داخل هذه الطريقة ، يتم الاحتفاظ بمحتواه داخليًا.
SaveLzipped(الشبكة، CpioFormat)
تخزين الأرشيف إلى التدفق باستخدام ضغط lzip.
public void SaveLzipped(Stream output, CpioFormat cpioFormat = CpioFormat.OldAscii)
Parameters
output
Stream
النطاق المستهدف
cpioFormat
CpioFormat
تحديد شكل 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
يجب أن تكون مكتوبة.
Exceptions
output’ is null.
output’ is not writable.
SaveLzipped(الكمبيوتر، CpioFormat)
حفظ الأرشيف إلى الملف عن طريق الطريق مع ضغط lzip.
public void SaveLzipped(string path, CpioFormat cpioFormat = CpioFormat.OldAscii)
Parameters
path
string
إذا كان اسم الملف المحدد يشير إلى ملف موجود ، فسيتم إعادة كتابته.
cpioFormat
CpioFormat
تحديد شكل 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)
توفير الأرشيف إلى التدفق مع ضغط xz.
public void SaveXzCompressed(Stream output, CpioFormat cpioFormat = CpioFormat.OldAscii, XzArchiveSettings settings = null)
Parameters
output
Stream
النطاق المستهدف
cpioFormat
CpioFormat
تحديد شكل cpio header.
settings
XzArchiveSettings
مجموعة إعدادات محددة xz أرشيف: حجم القاموس، حجم الكتلة، نوع التحقق.
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
يجب أن يكون التدفق مكتوبًا.
Exceptions
output’ is null.
output’ is not writable.
SaveXzCompressed(إعدادات, CpioFormat, XzArchiveSettings)
تخزين الأرشيف إلى الطريق عن طريق الطريق مع ضغط xz.
public void SaveXzCompressed(string path, CpioFormat cpioFormat = CpioFormat.OldAscii, XzArchiveSettings settings = null)
Parameters
path
string
إذا كان اسم الملف المحدد يشير إلى ملف موجود ، فسيتم إعادة كتابته.
cpioFormat
CpioFormat
تحديد شكل cpio header.
settings
XzArchiveSettings
مجموعة إعدادات محددة xz أرشيف: حجم القاموس، حجم الكتلة، نوع التحقق.
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");
}
}
أضف تعليق(الشبكة، CpioFormat)
توفير الأرشيف إلى التدفق مع ضغط Z.
public void SaveZCompressed(Stream output, CpioFormat cpioFormat = CpioFormat.OldAscii)
Parameters
output
Stream
النطاق المستهدف
cpioFormat
CpioFormat
تحديد شكل 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
يجب أن تكون مكتوبة.
Exceptions
output’ is null.
output’ is not writable.
أضف تعليق(الكمبيوتر، CpioFormat)
تخزين الأرشيف إلى المسار عن طريق الطريق مع ضغط Z.
public void SaveZCompressed(string path, CpioFormat cpioFormat = CpioFormat.OldAscii)
Parameters
path
string
إذا كان اسم الملف المحدد يشير إلى ملف موجود ، فسيتم إعادة كتابته.
cpioFormat
CpioFormat
تحديد شكل 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(الشبكة، CpioFormat)
حفظ الأرشيف إلى التدفق باستخدام ضغط Zstandard.
public void SaveZstandard(Stream output, CpioFormat cpioFormat = CpioFormat.OldAscii)
Parameters
output
Stream
النطاق المستهدف
cpioFormat
CpioFormat
تحديد شكل 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
يجب أن تكون مكتوبة.
Exceptions
output’ is null.
output’ is not writable.
SaveZstandard(الكمبيوتر، CpioFormat)
تخزين الأرشيف إلى الملف عن طريق الطريق مع ضغط Zstandard.
public void SaveZstandard(string path, CpioFormat cpioFormat = CpioFormat.OldAscii)
Parameters
path
string
إذا كان اسم الملف المحدد يشير إلى ملف موجود ، فسيتم إعادة كتابته.
cpioFormat
CpioFormat
تحديد شكل 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");
}
}