Coder Social home page Coder Social logo

olehkulykov / lzmasdkobjc Goto Github PK

View Code? Open in Web Editor NEW
168.0 168.0 44.0 3.63 MB

Lzma SDK for Swift and Objective-C ( iOS & MacOS ) based on extended functionality of the C++ LZMA SDK code.

License: MIT License

C 42.54% C++ 51.84% Objective-C 1.55% Objective-C++ 3.65% Ruby 0.42%

lzmasdkobjc's People

Contributors

enefry avatar jakubvano avatar olehkulykov avatar rhotta avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

lzmasdkobjc's Issues

Log spam in DEBUG

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?

Compress file in iOS and decompress in Java

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?

Encounter error SZ_ERROR_INPUT_EOF

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);

check .7z is encrypted

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

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}

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}

crash breakdown

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.

  • Codec was not compiled in or stripped by static linking. Make sure you are using 'use_frameworks!' and/or dynamic linking.
    2017-03-23 11:20:59.326 testLzma[70187:4145611] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'

use_frameworks!

Is it possible to use it under a purely static library project?

Extraction of one item in continuous archive leads to extraction of all items

Привет! Большое спасибо за библиотеку. Столкнулся со следующей проблемой:
пытаюсь распаковать один файл в непрерывном архиве, но в результате получаю не только этот файл, но и все те, которые находились перед ним.

Мой код:

    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.

"No suitable decoder found."

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?

LzmaSDKObjCExtractCallback.mm have some problem!

When i use function

  • (BOOL) extract:(nullable NSArray<LzmaSDKObjCItem *> *) items
    toPath:(nullable NSString *) path
    withFullPaths:(BOOL) isFullPaths

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;
}

Extract zip data from nsdata

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

Архив с папками не распаковывается вовсе или частично.

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

pass through not supported

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.

Compile error in 'lzma/cpp/windows/FileName.cpp'

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.

Can't create archive object file type: 1

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,

Being unable to install in a objc project, no swift inside.

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?

7z archive creation support?

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!

Extracting item from archive to NSData object (without saving it to disk)

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?

Encrypt and decrypt in memory

Привет! Спасибо за библиотеку. Есть вопрос: как можно реализовать сжатие и экстракт сразу в память? Т.е. хочется использовать что-то по типу
LzmaSDKObjCWriter * writer = [[LzmaSDKObjCWriter alloc] initWithBuffer: ]];
Чтобы я мог указать степень сжатия и шифрование контента

Ppmd codec

Hi,
I've statically linked the repo to my project, by adding files in podspec file:

  1. 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.

  2. 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

  3. 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>

Reader.extract should only extract the specified items

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.

Unarchive .7z file works randomly - LZMA DEBUG 72: ERROR: code = 1,

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.

an't create archive object file type: 1

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}

Swift compiler warnings (Xcode 10.1, Swift 4.2)

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!

About 7z-MultiVolume

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.