olehkulykov / lzmasdkobjc Goto Github PK
View Code? Open in Web Editor NEWLzma SDK for Swift and Objective-C ( iOS & MacOS ) based on extended functionality of the C++ LZMA SDK code.
License: MIT License
Lzma SDK for Swift and Objective-C ( iOS & MacOS ) based on extended functionality of the C++ LZMA SDK code.
License: MIT License
Привет! Большое спасибо за библиотеку. Столкнулся со следующей проблемой:
пытаюсь распаковать один файл в непрерывном архиве, но в результате получаю не только этот файл, но и все те, которые находились перед ним.
Мой код:
NSURL *url = [NSURL fileURLWithPath:@"/Users/Admin/Desktop/1.7z"];
LzmaSDKObjCReader *lzmaArch = [[LzmaSDKObjCReader alloc] initWithFileURL:url];
if (![lzmaArch open:nil])
return;
__block NSError *iterateError;
NSMutableArray *items = [[NSMutableArray alloc] init];
[lzmaArch iterateWithHandler:^BOOL(LzmaSDKObjCItem * item, NSError *error)
{
if (error)
iterateError = error;
[items addObject:item];
return error == nil;
}];
if (iterateError)
return;
// извлекаем только 5й LzmaSDKObjCItem, но по факту извлекутся первые 5
[lzmaArch extract:@[items[4]] toPath:@"/Users/Admin/Desktop" withFullPaths:NO];
Проблемный файл пришлось дополнительно запаковать в zip, так как Github не поддерживает прикрепление .7z
1.7z.zip
С обычными архивами таких проблем, разумеется, нет - извлекает только указанный item.
Howdy - I see that support for creating and updating 7z archives is on your roadmap. Curious if there's an ETA for this functionality?
Thanks!
ERROR: code = -1, file = '/Users/xxx/Desktop/LzmaSDKObjC-0.0.8/src/LzmaSDKObjCFileDecoder.cpp', line = 185, description = Can't create archive object file type: 12016-03-28 17:53:04:357 TaeExam[3465:668038] Open error: Error Domain=LzmaSDKObjCReader Code=-1 "Can't create archive object file type: 1" UserInfo={code=-1, line=185, file=/Users/xxx/Desktop/LzmaSDKObjC-0.0.8/src/LzmaSDKObjCFileDecoder.cpp, NSLocalizedDescription=Can't create archive object file type: 1}
Hello ,
I have a base64 string which I am converting to nsdata and that nsdata is in 7zip format , I want to decompress the data using LzmaSDKObjCBufferDecompressLZMA2 function but I am not able to decompress it . my result is always 0 bytes .
can you point me to correct direction
you sdk unarchive simple .7z very good. but unarchive very dictionary/dictionary/dictionary
ep. 223/224/225/i love you.mp3 failure . can you help me ? please.
my [email protected]
Currently it is only possivble no uncompress the whole file, but that is not really enough for a productive app, uncompressing single files inside the 7z should be possible.
Hi,
I am trying to download file and unarchive it in my app. The problem is that sometimes Lzma works perfectly but most of the time I am getting this error in console:
LZMA DEBUG 72: ERROR: code = 1, file = '/Users/piotrek/Development/zarazjade_mac/Pods/LzmaSDK-ObjC/src/LzmaSDKObjCFileDecoder.cpp', line = 146, description = Can't open archive file with result: 1
Can't open archive: Can't open archive file with result: 1
There is a code that unzip my file:
guard let fileURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first else { return }
let reader = LzmaSDKObjCReader(fileURL: fileURL.appendingPathComponent(lastFile.name), andType: LzmaSDKObjCFileType7z)
reader.delegate = self
reader.passwordGetter = {
return ""
}
do {
try reader.open()
var items = [LzmaSDKObjCItem]()
reader.iterate(handler: { (item, error) -> Bool in
items.append(item)
return true
})
if reader.extract(items, toPath: "/Users/piotrek/Documents/", withFullPaths: true) {
print("Extract failed: \(reader.lastError?.localizedDescription)")
}
} catch let error as NSError {
print("Can't open archive: \(error.localizedDescription) ")
}
I will be glad for help.
how can I check .7z file has encrypted.
I try this way
var items = [LzmaSDKObjCItem]()
reader.iterate { (item: LzmaSDKObjCItem, error: Error?) -> Bool in
print(item.isEncrypted)
items.append(item)
return true
}
but its not work,
the item cannot be read because the password is incorrect.
So I want to make sure that the file has a password, and if it does, I'll prompt the user for a password
Hope to get your answer
Hi,
How can I get to know a 7zip file is password protected. Right now the library is throwing a generic error
Hello,
I am using LzmaSDKObjC via Cocoapods in a Swift project. While the code works fine, the Swift Compiler is throwing up the following warnings:
/LzmaSDK-ObjC/LzmaSDK_ObjC.framework/Headers/LzmaSDKObjCWriter.h:212:1: warning: conflicting nullability specifier on return types, 'nullable' conflicts with existing specifier 'nonnull'
- (nullable instancetype) init NS_UNAVAILABLE;
LzmaSDK-ObjC/LzmaSDK_ObjC.framework/Headers/LzmaSDKObjCWriter.h:213:1: warning: conflicting nullability specifier on return types, 'nullable' conflicts with existing specifier 'nonnull'
+ (nullable instancetype) new NS_UNAVAILABLE;
LzmaSDK-ObjC/LzmaSDK_ObjC.framework/Headers/LzmaSDKObjCReader.h:162:1: warning: conflicting nullability specifier on return types, 'nullable' conflicts with existing specifier 'nonnull'
- (nullable instancetype) init NS_UNAVAILABLE;
LzmaSDK-ObjC/LzmaSDK_ObjC.framework/Headers/LzmaSDKObjCReader.h:163:1: warning: conflicting nullability specifier on return types, 'nullable' conflicts with existing specifier 'nonnull'
+ (nullable instancetype) new NS_UNAVAILABLE;
Thanks!
ERROR: code = -1, file = '/Users/xxx/Desktop/LzmaSDKObjC-0.0.8/src/LzmaSDKObjCFileDecoder.cpp', line = 185, description = Can't create archive object file type: 12016-03-28 17:53:04:357 TaeExam[3465:668038] Open error: Error Domain=LzmaSDKObjCReader Code=-1 "Can't create archive object file type: 1" UserInfo={code=-1, line=185, file=/Users/xxx/Desktop/LzmaSDKObjC-0.0.8/src/LzmaSDKObjCFileDecoder.cpp, NSLocalizedDescription=Can't create archive object file type: 1}
I‘m use static Libray,LzmaSDKObjC-0.0.8,
When following the example Swift in the ReadMe, I've noticed that reader.extract
, rather than extracting only the specified items, appears to incorrectly extract items that were not specified.
I observe that the incorrectly extracted items, appear to be those items that precede the specified items in the archive.
What's time update?
The code is as below:
pucCompressedData = new unsigned char[MAX_COMPRESS_DATA];
p_pTargetImgPtr = new unsigned char[MAX_COMPRESS_DATA];
szOutProps = new unsigned char[5];
iLzmaCompressionStatus = LzmaCompress(pucCompressedData, (size_t *)&uiCompressedDataSize,
pucBuffer, iTempFileSize,
szOutProps, (size_t *)&uiOutPropsSize,
iLevel,
uiDict_size,
iLc,
iLp,
iPb,
iFb,
iNumThreads);
uiUncompressedDataSize = SZ-1;
int iLzmaUncompressStatus = LzmaUncompress(
/* 1 */ p_pTargetImgPtr,
/* 2 */ (size_t*)&uiUncompressedDataSize,
/* 3 */ pucCompressedData,
/* 4 */ (size_t*)&uiCompressedDataSize,
/* 5 */ szOutProps,
/* 6 */ (size_t)uiOutPropsSize);
There is warning of LzmaSDKObjCWriter's init function saying that the target file will be deleted
@warning Prev. path will be deleted.
How to add a file to a .7z file or remove an entry from .7z file please?
If the size of files added are over 4g, how can I archive them to a big .7z file over 4g? Thank you very much!
Hello, how do I use the sdk to do split volume compression
I am being unable to add this SDK to my project, I added the pod and run pod install but when trying to call reader open
I am getting following warning in the console:
LZMA DEBUG 85: ERROR REASON: - Unsupported archive GUID.
- Codec was not compiled in or stripped by static linking. Make sure you are using 'use_frameworks!' and/or dynamic linking.
Is there anything else than only adding the pod necessary to be able to run this? I am also not sure about following line in the documentation about "Installation":
Use frameworks (dynamic linking) to include Lzma codecs code in your application.
Does this mean that use_frameworks! MUST be added to the pod file in order for this SDK to work?
There are a ton of log messages in DEBUG. Would it be OK to add a way to turn that off, even in DEBUG mode?
Hi, I want to interrupt the compression/decompression process, what should I do ?
Hope to get your answer.
LZMA DEBUG 72: ERROR: code = -1, file = '/Users/X/Desktop/testLzma/Pods/LzmaSDK-ObjC/src/LzmaSDKObjCBaseCoder.cpp', line = 50, description = Can't create archive object file type: 1
LZMA DEBUG 85: ERROR REASON: - Unsupported archive GUID.
Привет! Спасибо за библиотеку. Есть вопрос: как можно реализовать сжатие и экстракт сразу в память? Т.е. хочется использовать что-то по типу
LzmaSDKObjCWriter * writer = [[LzmaSDKObjCWriter alloc] initWithBuffer: ]];
Чтобы я мог указать степень сжатия и шифрование контента
when i open the { #define _7Z_VOL } in the 7zHeader.h, i got some error, can you help me to fix the
error, i want to make 7z multi-volume archives on the mobile devices, thanks very much.
BOOL Done = [reader extract:items toPath:destionation withFullPaths:YES];
Done всегда NO; и ничего не распаковывает.
Если withFullPaths:NO то Done тоже NO, при этом распаковывает, но все файлы из папок кидает в одну.
Тестил на этом файле
http://files.d-lan.dp.ua/download.php?file=a2b9d437ea26b638e7b2b7df99e1cf8f
Open error: Error Domain=LzmaSDKObjCReader Code=-1 "Can't create archive object file type: 1" UserInfo={code=-1, NSLocalizedDescription=Can't create archive object file type: 1, file=/Users/kjx/XHWorkStation/XHEnglishBrushStudent/Pods/LzmaSDK-ObjC/src/LzmaSDKObjCFileDecoder.cpp, line=185}
When i use function
like this
[reader extract:items
toPath:deleteLastpath
withFullPaths:YES];
It isn't giving dictionary.
I found "LzmaSDKObjCExtractCallback.mm" line 105 "subPath" is wrong.
It is ok. As follows:
NSString * subPathNew =[fullPath stringByAppendingString: subPath];
if ([manager fileExistsAtPath:subPathNew isDirectory:&isDir]) {
if (!isDir) {
this->setLastError(E_ABORT, LINE, FILE, "Destination path: [%s] exists in directory: [%s] and it's file", [subPath UTF8String], [fullPath UTF8String]);
return E_ABORT;
}
} else if (![manager createDirectoryAtPath:subPathNew withIntermediateDirectories:YES attributes:nil error:&error] || error) {
this->setLastError(E_ABORT, LINE, FILE, "Can't create subdirectory: [%s] in directory: [%s]", [subPath UTF8String], [fullPath UTF8String]);
return E_ABORT;
}
Please check ZipArchive/ZipArchive#326 and the link to blog inside issue.
Hi,
I've statically linked the repo to my project, by adding files in podspec
file:
In LzmaSDKObjCReader.mm
resetting prop
variable using { 0 }
is not possible in c, so I got error. I searched in stackoverflow and resolved this by replacing { 0 }
with PROPVARIANT()
. Another way is to declare PROPVARIANT emptyProp = { 0 };
and resetting prop
variable by setting to emptyProp
, or declare different variables for each part.
I've found out Ppmd (de)coder files aren't added to pods (and I didn't added so), consequently I couldn't extract Ppmd test file. I've added this files and resolved the problem
I've also added ByteSwap, Copy and Bcj2 (de)coder files. Only had an small issue in Bcj2Enc.c
file which resolved by commenting #include <windows.h>
Seems to fail out on uncompressed archives. My project has about 15 gigabytes of data that needs to be zipped and transferred. This data is image related and encrypted already. I was getting failures with kUnsupportedMethod when running in pass-through mode (-mx0) while compressing. The solution for now at least for me is to compress my archives, but compressing 15 gigabytes of encrypted data takes hours instead of a couple of minutes in pass through.
It would seem to be a trivial case to add "no compression" as an available compression method. From what I can tell it has to be explicitly compressed with LZMA or LZMA2 for this kit to work.
。。。
Is it possible to use it under a purely static library project?
Using the sample code, with a valid .7z file, I get the message:
Open error: Error Domain=LzmaSDKObjCReader Code=-1 "No suitable decoder found."
Running on iOS 9.1, Xcode 7.1.1.
Seems to be because CreateObject is not returning S_OK, I couldn't get further than this though?
I've found error ['IsAbsolutePath' is missing exception specification 'throw()'] and ['GetRootPrefixSize' is missing exception specification 'throw()'] while compiling file 'lzma/cpp/windows/FileName.cpp'. It seems this file has been removed from master branch but cocoapod somehow still retrieve it.
Hi, I want to transfer a file from an Ipad to an Java web application.
In iOS I use the LzmaSDKObjCBufferCompressLZMA2 to compress the file content:
if let data = NSData(contentsOfFile: pathToFile)
{
if let compress = LzmaSDKObjCBufferCompressLZMA2(data, 0)
{
compress.writeToFile(backupPath, atomically: true)
}
}
But on server side neither decompressor (XZ utils, Apache Commons Compressor) is able to detect the file content as valid format.
So my question is: What do I have to do in order to save a valid LZMA(2) compressed file that can be decompressed by those libraries?
LzmaSDKObjC-ObjC.framework including in project,but it is not work.
Hello,
This library is the best available for iOS in term of archiving unarchiving protected files.
It will be good to add additional features that would make it even better:
In certain scenarios extracting a file to disk and then reading it back into NSData is too cumbersome, specially when the only thing that is needed is to process the NSData.
It will be good to have the ability to extract an item from an archive directly as NSData.
Is that something that is possible?
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.