deltajordan / archivemanagersharp Goto Github PK
View Code? Open in Web Editor NEWAims to be a program that can manage as many types of archives as possible
License: MIT License
Aims to be a program that can manage as many types of archives as possible
License: MIT License
When a file from the viewing window of the program is opened or extracted from a password-protected rar file, the resulting file is corrupted. The problem is the library this application uses to open the archive, SharpCompress, does not have a check for passwords for rars and also does not have validation for file data, like CRC. I may have to find a way to validate the file, possibly by the file size because it seems to create an empty file.
Need to keep an eye on CRC Validation support in SharpCompress: adamhathcock/sharpcompress#246
public static class UniversalArchiver
{
public static void ExtractAll(string archiveFilePath, string destinationFolder, string password)
{
Directory.CreateDirectory(destinationFolder);
var fileInfo = new FileInfo(archiveFilePath);
var readerOptions = new ReaderOptions { Password = password };
var extractionOptions = new ExtractionOptions { ExtractFullPath = true, Overwrite = true, PreserveAttributes = false, PreserveFileTime = true };
var archiveType = GetArchiveType(Path.GetExtension(archiveFilePath));
IArchive archive;
switch (archiveType)
{
case ArchiveType.Rar:
archive = RarArchive.Open(fileInfo, readerOptions);
break;
case ArchiveType.Zip:
archive = ZipArchive.Open(fileInfo, readerOptions);
break;
case ArchiveType.Tar:
archive = TarArchive.Open(fileInfo, readerOptions);
break;
case ArchiveType.SevenZip:
archive = SevenZipArchive.Open(fileInfo, readerOptions);
break;
case ArchiveType.GZip:
archive = GZipArchive.Open(fileInfo, readerOptions);
break;
default:
throw new ArgumentOutOfRangeException(nameof(archiveType), archiveType, null);
}
archive.WriteToDirectory(destinationFolder, extractionOptions);
archive.Dispose();
}
private static ArchiveType GetArchiveType(string extension)
{
switch (extension.Replace(".", string.Empty).ToLowerInvariant())
{
case "rar":
return ArchiveType.Rar;
case "zip":
case "zipx":
return ArchiveType.Zip;
case "tar":
return ArchiveType.Tar;
case "7z":
return ArchiveType.SevenZip;
case "gz":
return ArchiveType.GZip;
default:
throw new ArchiveException("Unknown file type!");
}
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.