Noyacode.CabinetManager
1.0.3
.NET Standard 2.0
This package targets .NET Standard 2.0. The package is compatible with this framework or higher.
.NET Framework 4.6.1
This package targets .NET Framework 4.6.1. The package is compatible with this framework or higher.
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Noyacode.CabinetManager --version 1.0.3
NuGet\Install-Package Noyacode.CabinetManager -Version 1.0.3
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Noyacode.CabinetManager" Version="1.0.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Noyacode.CabinetManager --version 1.0.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Noyacode.CabinetManager, 1.0.3"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Noyacode.CabinetManager as a Cake Addin #addin nuget:?package=Noyacode.CabinetManager&version=1.0.3 // Install Noyacode.CabinetManager as a Cake Tool #tool nuget:?package=Noyacode.CabinetManager&version=1.0.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Microsoft cabinet file specifications
This library implements the following specifications:
https://msdn.microsoft.com/en-us/library/bb417343.aspx#cabinet_format
Limitations of this lib
This library is not a complete implementation of the specifications (mostly because I didn't need all the features).
The limitations are listed below:
- Does not handle multi-cabinet file (a single cabinet can hold up to ~2Gb of data)
- Does not handle compressed data, you can only store/retrieve uncompressed data
- Does not compute nor verify checksums
Usage example
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using CabinetManager;
namespace CabinetManagerTest {
public class Program {
static void Main(string[] args) {
Console.WriteLine("Creating dumb file.");
File.WriteAllText(@"my_source_file.txt", @"my content");
var cabManager = CabManager.New();
cabManager.SetCompressionLevel(CabCompressionLevel.None);
cabManager.SetCancellationToken(null);
cabManager.OnProgress += CabManagerOnProgress;
// Add files to a new or existing cabinet
Console.WriteLine("Adding file to cabinet.");
var nbProcessed = cabManager.PackFileSet(new List<IFileToAddInCab> {
CabFile.NewToPack(@"archive.cab", @"folder\file.txt", @"my_source_file.txt")
});
Console.WriteLine($" -> {nbProcessed} files were added to a cabinet.");
// List all the files in a cabinet
var filesInCab = cabManager.ListFiles(@"archive.cab").ToList();
Console.WriteLine("Listing files:");
foreach (var fileInCab in filesInCab) {
Console.WriteLine($" * {fileInCab.RelativePathInCab}: {fileInCab.LastWriteTime}, {fileInCab.SizeInBytes}, {fileInCab.FileAttributes}");
}
// Extract files to external paths
Console.WriteLine("Extract file from cabinet.");
nbProcessed = cabManager.ExtractFileSet(new List<IFileInCabToExtract> {
CabFile.NewToExtract(@"archive.cab", @"folder\file.txt", @"extraction_path.txt")
});
Console.WriteLine($" -> {nbProcessed} files were extracted from a cabinet.");
// Move files within a cabinet
var filesToMove = filesInCab.Select(f => CabFile.NewToMove(f.CabPath, f.RelativePathInCab, $"subfolder/{f.RelativePathInCab}")).ToList();
Console.WriteLine("Moving files within a cabinet.");
nbProcessed = cabManager.MoveFileSet(filesToMove);
Console.WriteLine($" -> {nbProcessed} files were moved within the cabinet.");
// Delete files in a cabinet
Console.WriteLine("Delete file in cabinet.");
nbProcessed = cabManager.DeleteFileSet(filesToMove.Select(f => CabFile.NewToDelete(f.CabPath, f.NewRelativePathInCab)));
Console.WriteLine($" -> {nbProcessed} files were deleted from a cabinet.");
}
private static void CabManagerOnProgress(object sender, ICabProgressionEventArgs e) {
switch (e.EventType) {
case CabEventType.GlobalProgression:
Console.WriteLine($"Global progression : {e.PercentageDone}%, current file is {e.RelativePathInCab}");
break;
case CabEventType.FileProcessed:
Console.WriteLine($"New file processed : {e.RelativePathInCab}");
break;
case CabEventType.CabinetCompleted:
Console.WriteLine($"New cabinet completed : {e.CabPath}");
break;
}
}
private class CabFile : IFileInCabToDelete, IFileInCabToExtract, IFileToAddInCab, IFileInCabToMove {
public string CabPath { get; private set; }
public string RelativePathInCab { get; private set; }
public string ExtractionPath { get; private set; }
public string SourcePath { get; private set; }
public string NewRelativePathInCab { get; private set; }
public static CabFile NewToPack(string cabPath, string relativePathInCab, string sourcePath) {
return new CabFile {
CabPath = cabPath,
RelativePathInCab = relativePathInCab,
SourcePath = sourcePath
};
}
public static CabFile NewToExtract(string cabPath, string relativePathInCab, string extractionPath) {
return new CabFile {
CabPath = cabPath,
RelativePathInCab = relativePathInCab,
ExtractionPath = extractionPath
};
}
public static CabFile NewToDelete(string cabPath, string relativePathInCab) {
return new CabFile {
CabPath = cabPath,
RelativePathInCab = relativePathInCab
};
}
public static CabFile NewToMove(string cabPath, string relativePathInCab, string newRelativePathInCab) {
return new CabFile {
CabPath = cabPath,
RelativePathInCab = relativePathInCab,
NewRelativePathInCab = newRelativePathInCab
};
}
}
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 is compatible. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETFramework 4.6.1
- No dependencies.
-
.NETStandard 2.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Learn more about this project on github: https://jcaillon.github.io/CabinetManager.
See more details about this release on github: https://github.com/jcaillon/CabinetManager/releases.