Giter Club home page Giter Club logo

unrarkit's Introduction

Build Status Cocoapods Carthage compatible Cocoapods platforms

About

UnrarKit is here to enable Mac and iOS apps to easily work with RAR files for read-only operations. It is currently based on version 5.8.1 of the UnRAR library.

There is a main project, with unit tests, and a basic iOS example project, which demonstrates how to use the library. To see all of these, open the main workspace file.

I'm always open to improvements, so please submit your pull requests, or create issues for someone else to implement.

Installation

UnrarKit supports both CocoaPods and Carthage. CocoaPods does not support dynamic framework targets (as of v0.39.0), so in that case, please use Carthage.

Cartfile:

github "abbeycode/UnrarKit"

Podfile:

pod "UnrarKit"

Example Usage

NSError *archiveError = nil;
URKArchive *archive = [[URKArchive alloc] initWithPath:@"An Archive.rar" error:&archiveError];
NSError *error = nil;

Listing the file names in an archive

NSArray<String*> *filesInArchive = [archive listFilenames:&error];
for (NSString *name in filesInArchive) {
    NSLog(@"Archived file: %@", name);
}

Listing the file details in an archive

NSArray<URKFileInfo*> *fileInfosInArchive = [archive listFileInfo:&error];
for (URKFileInfo *info in fileInfosInArchive) {
    NSLog(@"Archive name: %@ | File name: %@ | Size: %lld", info.archiveName, info.filename, info.uncompressedSize);
}

Working with passwords

NSArray<URKFileInfo*> *fileInfosInArchive = [archive listFileInfo:&error];
if (archive.isPasswordProtected) {
    NSString *givenPassword = // prompt user
    archive.password = givenPassword
}

// You can now extract the files

Extracting files to a directory

BOOL extractFilesSuccessful = [archive extractFilesTo:@"some/directory"
                                            overWrite:NO
                                                error:&error];

Extracting a file into memory

NSData *extractedData = [archive extractDataFromFile:@"a file in the archive.jpg"
                                               error:&error];

Streaming a file

For large files, you may not want the whole contents in memory at once. You can handle it one "chunk" at a time, like so:

BOOL success = [archive extractBufferedDataFromFile:@"a file in the archive.jpg"
                                              error:&error
                                             action:
                ^(NSData *dataChunk, CGFloat percentDecompressed) {
                    NSLog(@"Decompressed: %f%%", percentDecompressed);
                    // Do something with the NSData chunk
                }];

Progress Reporting

The following methods support NSProgress and NSProgressReporting:

  • extractFilesTo:overwrite:error:
  • extractData:error:
  • extractDataFromFile:error:
  • performOnFilesInArchive:error:
  • performOnDataInArchive:error:
  • extractBufferedDataFromFile:error:action:

Using implicit NSProgress hierarchy

You can create your own instance of NSProgress and observe its fractionCompleted property with KVO to monitor progress like so:

    static void *ExtractDataContext = &ExtractDataContext;

    URKArchive *archive = [[URKArchive alloc] initWithURL:aFileURL error:nil];

    NSProgress *extractDataProgress = [NSProgress progressWithTotalUnitCount:1];
    [extractDataProgress becomeCurrentWithPendingUnitCount:1];

    NSString *observedSelector = NSStringFromSelector(@selector(fractionCompleted));

    [extractDataProgress addObserver:self
                          forKeyPath:observedSelector
                             options:NSKeyValueObservingOptionInitial
                             context:ExtractDataContext];

    NSError *extractError = nil;
    NSData *data = [archive extractDataFromFile:firstFile error:&extractError];

    [extractDataProgress resignCurrent];
    [extractDataProgress removeObserver:self forKeyPath:observedSelector];

Using your own explicit NSProgress instance

If you don't have a hierarchy of NSProgress instances, or if you want to observe more details during progress updates in extractFilesTo:overwrite:error:, you can create your own instance of NSProgress and set the URKArchive instance's progress property, like so:

    static void *ExtractFilesContext = &ExtractFilesContext;

    URKArchive *archive = [[URKArchive alloc] initWithURL:aFileURL error:nil];

    NSProgress *extractFilesProgress = [NSProgress progressWithTotalUnitCount:1];
    archive.progress = extractFilesProgress;

    NSString *observedSelector = NSStringFromSelector(@selector(localizedDescription));

    [self.descriptionsReported removeAllObjects];
    [extractFilesProgress addObserver:self
                           forKeyPath:observedSelector
                              options:NSKeyValueObservingOptionInitial
                              context:ExtractFilesContext];

    NSError *extractError = nil;
    BOOL success = [archive extractFilesTo:extractURL.path
                                 overwrite:NO
                                     error:&extractError];

    [extractFilesProgress removeObserver:self forKeyPath:observedSelector];

Cancellation with NSProgress

Using either method above, you can call [progress cancel] to stop the operation in progress. It will cause the operation to fail, returning nil or NO (depending on the return type, and give an error with error code URKErrorCodeUserCancelled.

Notes

To open in Xcode, use the UnrarKit.xcworkspace file, which includes the other projects.

The example app

Included in the source repo is a project named "UnrarExample", that builds as part of the main solution. It's only ever verified to run in the simulator, but if you provide Team info, it should probably also run on-device.

For large file extraction, the tool uses the rar executable. You may need to right-click and open it in Finder to get through Gatekeeper the first time you do so.

Documentation

Full documentation for the project is available on CocoaDocs.

Logging

For all OS versions from 2016 onward (macOS 10.12, iOS 10, tvOS 10, watchOS 3), UnzipKit uses the new Unified Logging framework for logging and Activity Tracing. You can view messages at the Info or Debug level to view more details of how UnzipKit is working, and use Activity Tracing to help pinpoint the code path that's causing a particular error.

As a fallback, regular NSLog is used on older OSes, with all messages logged at the same level.

When debugging your own code, if you'd like to decrease the verbosity of the UnrarKit framework, you can run the following command:

sudo log config --mode "level:default" --subsystem com.abbey-code.UnrarKit

The available levels, in order of increasing verbosity, are default, info, debug, with debug being the default.

Logging guidelines

These are the general rules governing the particulars of how activities and log messages are classified and written. They were written after the initial round of log messages were, so there may be some inconsistencies (such as an incorrect log level). If you think you spot one, open an issue or a pull request!

Logging

Log messages should follow these conventions.

  1. Log messages don't have final punctuation (like these list items)
  2. Messages that note a C function is about to be called, rather than a higher level UnrarKit or Cocoa method, end with "...", since it's not expected for them to log any details of their own

Default log level

There should be no messages at this level, so that it's possible for a consumer of the API to turn off all diagnostic logging from it, as detailed above. It's only possible to log config --mode "level:off" for a process, not a subsystem.

Info log level

Info level log statements serve the following specific purposes.

  1. Major action is taken, such as initializing an archive object, or deleting a file from an archive
  2. Noting each public method has been called, and the arguments with which it was called
  3. Signposting the major actions a public method takes
  4. Notifying that an atypical condition has occurred (such as an action causing an early stop in a block or a NO return value)
  5. Noting that a loop is about to occur, which will contain debug-level messages for each iteration

Debug log level

Most messages fall into this category, making it extremely verbose. All non-error messages that don't fall into either of the other two categories should be debug-level, with some examples of specific cases below.

  1. Any log message in a private method
  2. Noting variable and argument values in a method
  3. Indicating that everything is working as expected
  4. Indicating what happens during each iteration of a loop (or documenting that an iteration has happened at all)

Error log level

  1. Every NSError generated should get logged with the same detail message as the NSError object itself
  2. NSError log messages should contain the string of the error code's enumeration value (e.g. "URKErrorCodeArchiveNotFound") when it is known at design time
  3. Errors should reported everywhere they're encountered, making it easier to trace their flows through the call stack
  4. Early exits that result in desired work not being performed

Fault log level

Used when a Cocoa framework method comes back with an error. There are only a handful of uses

Activities

  1. Public methods have an English activity names with spaces, and are title-case
  2. Private methods each have an activity with the method's name
  3. Sub-activities are created for significant scope changes, such as when inside an action block, but not if no significant work is done before entering that action
  4. Top-level activities within a method have variables named activity, with more specific labels given to sub-activities
  5. If a method is strictly an overload that calls out to another overload without doing anything else, it should not define its own activity

Pushing a new CocoaPods version

New tagged builds (in any branch) get pushed to CocoaPods automatically, provided they meet the following criteria:

  1. All builds and tests succeed
  2. The library builds successfully for CocoaPods and for Carthage
  3. The build is tagged with something resembling a version number (#.#.#(-beta#), e.g. 2.9 or 2.9-beta5)
  4. pod spec lint passes, making sure the CocoaPod is 100% valid

Before pushing a build, you must:

  1. Add the release notes to the CHANGELOG.md, and commit

  2. Run set-version, like so:

    ./Scripts/set-version.sh <version number>

    This does the following:

    1. Updates the UnrarKit-Info.plist file to indicate the new version number, and commits it

    2. Makes an annotated tag whose message contains the release notes entered in Step 1

Once that's done, you can call git push --follow-tags 1, and let Travis CI take care of the rest.

Note: if the push to CocoaPods fails in Travis CI, it's almost certainly because the Trunk token has expired. Follow this Stack Overflow answer's instructions to fix it. Next time, try pod trunk me

Credits


1: Or set followTags = true in your git config to always get this behavior:

git config --global push.followTags true

โ†ฉ

unrarkit's People

Contributors

abbeycode avatar aonez avatar ararog avatar fillito avatar flambert avatar gpotari avatar scinfu 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

unrarkit's Issues

Add API for reporting progress in a block callback

Add something akin to these overloads:

- (BOOL)extractFilesTo:(NSString *)filePath
             overWrite:(BOOL)overwrite
              progress:(void (^)(URKFileInfo *currentFile, CGFloat percentFileDecompressed, CGFloat percentArchiveDecompressed))progress
                 error:(NSError **)error;

- (NSData *)extractDataFromFile:(NSString *)filePath
                       progress:(void (^)(CGFloat percentDecompressed))progress
                          error:(NSError **)error;

extractFilesTo path bug

Hello!

I'm trying to unrar this file (happens with others too):
https://www.dropbox.com/s/q0w8gatjobx2puq/rarWithoutPassword.rar?dl=0

I'm using the method extractFilesTo and for the destination path i'm creating a folder with the same name of the file

NSString *destination = [[file URLByDeletingPathExtension] path];

The extract is working, but there is a very strange bug. The rar i provided for download has 2 .txt on it and this is the result i got from its extraction:

unrar_bug

It creates a folder for each file inside the rar. The last characters of the folder name always has strange charsets (this time is a japanese thing lol). This bug don't happens 100% all the times, but happens a lot.

I got a solution for this but probably it's not the right way to fix it, i really don't know what is causing this bug. (i'm testing in iOS Simulator, 8.3 - Xcode 6.3.2, installed UnrarKit from the cocoa pods
)

URKArchive.mm - Line 274

if ((PFCode = RARProcessFileW(_rarFile, RAR_EXTRACT, unicharsFromString(filePath), NULL)) != 0)

change to ->

if ((PFCode = RARProcessFile(_rarFile, RAR_EXTRACT, (char *) [filePath UTF8String], NULL)) != 0)

Thanks!

Feature request. Custom callback methods

int CALLBACK CallbackProc(UINT msg, long UserData, long P1, long P2)
int CALLBACK BufferedReadCallbackProc(UINT msg, long UserData, long P1, long P2)
These functions can be accessed from the code inside URKArchive.mm.
What about to add a public way to access them? For example I want to customize UCM_CHANGEVOLUME event

Upgrade to Xcode 9

  • Upgrade project
  • Fix any new warnings
  • Fix any broken test cases
  • Fix any CocoaPods/Carthage validation problems

Unknown type name 'class'; did you mean 'Class'?

Hi ,
when I install UnrarKit in my project (with cocoa pod) ,
and import UnrarKit through a bridging header :

import "UnrarKit/UnrarKit.h"

I get those error :
for archive.hpp
archive.hpp:4:1: Unknown type name 'class'; did you mean 'Classโ€™?
archive.hpp:5:1: Unknown type name 'class'; did you mean 'Classโ€™?
archive.hpp:6:1: Unknown type name 'class'; did you mean 'Classโ€™?
archive.hpp:23:1: Unknown type name 'class'; did you mean 'Class'?
archive.hpp:23:26: Expected ';' after top level declarator
archive.hpp:23:15: Unknown type name โ€˜public'

for array.hpp
array.hpp:4:8: Unknown type name 'ErrorHandler'; did you mean 'ProcHandleโ€™?
array.hpp:6:1: Unknown type name โ€˜template'
array.hpp:6:10: Expected identifier or โ€˜('
array.hpp:33:1: Unknown type name โ€˜template'
array.hpp:33:10: Expected identifier or โ€˜('
array.hpp:42:1: Unknown type name โ€˜template'
array.hpp:42:10: Expected identifier or โ€˜('
array.hpp:48:1: Unknown type name โ€˜template'
array.hpp:48:10: Expected identifier or โ€˜('
array.hpp:56:1: Unknown type name โ€˜template'
array.hpp:56:10: Expected identifier or โ€˜('
array.hpp:65:1: Unknown type name โ€˜template'

then for my bridging header :
Too many errors emitted, stopping now

can you help me ?

PS: I don't think the problem come from the code I think the compiler act like the files .hpp are Objective C and not C++ code .

UnRar file have password in swift not work

Hi guy. Thank you create and support unbar lib . i'm use lib in swift and i got the problem, i can't extract file have password protected . this is my code

var archive : URKArchive?

do {
    archive = try URKArchive(path: files.filePath.path)
    let isPass =  archive?.isPasswordProtected();
    if isPass == true {
        try archive?.extractFiles(to: unzipURL.path, overwrite: true, progress: { (currenyFile, percentLoad) in
            if (percentLoad >= 1.0) {
                self.reloadFilesData()
            }
        })
    }
}
catch{

}

18:03:13.870928+0700 TheUnarchiver[50668:720439] [Common] _BSMachError: port 7c0f; (os/kern) invalid capability (0x14) "Unable to insert COPY_SEND"
2017-08-15 18:03:13.871261+0700 TheUnarchiver[50668:720439] [Common] _BSMachError: port 7c0f; (os/kern) invalid name (0xf) "Unable to deallocate send right"
please help me thank !!!

Localize strings

Following UnzipKit's example, localize all strings to a resource bundle distributed with the framework.

libunrar.a skip install in v2.9-beta5

When archiving an app using the framework, libunrar.a is exported. Skip install flag should be set as TRUE on unrar target build settings.

Also dll.hpp and raros.hpp libraries are exported, but I can't figure out how to skip those.

No support for Unicode in filenames

I'm bringing this issue over from ararog/Unrar4iOS#5.

I suspect this is because we use the FileName field from RARHeaderDataEx:

[NSString stringWithCString:header->FileName encoding:NSASCIIStringEncoding];

We should look at using FileNameW (UTF-8?) throughout UnrarKit so it can support unicode filenames.

Allow buffered reading of individual files

Right now, we can decompress the entire RAR archive or we can decompress a single file in the archive entirely into memory.

Ideally, it would be nice to be able to read a single file but not entirely into memory at once. Using a read-then-write buffer would allow us to extract individual files of an arbitrary length without hitting the iOS memory limits.

Here an example of how the objective-zip library handles this.

This would be a really nice enhancement of this library. Thanks for your work maintaining UnrarKit!

Make listFiles return more file metadata than just filenames

Another potential enhancement would be for the listFiles method to return an NSArray of a URKFileInfo instead of just an array of NSString file paths .

This URKFileInfo could contain some more useful metadata that we have available to us in the RAR header via RARReadHeaderEx.

Perhaps something like:

typedef NS_OPTIONS(NSUInteger, URKFileFlags) {
    URKFileFlagsFileContinuedFromPreviousVolume     = 1 << 0,
    URKFileFlagsFileContinuedOnNextVolume           = 1 << 1,
    URKFileFlagsFileEncryptedWithPassword           = 1 << 2,
    URKFileFlagsFileCommentPresent                  = 1 << 3,
    // TODO: Add remaining FileFlags in that are specified in bits 7, 6, and 5
};

typedef NS_ENUM(NSUInteger, URKPackingMethod) {
    URKPackingMethodStorage                         = 0x30,
    URKPackingMethodFastestCompression              = 0x31,
    URKPackingMethodFastCompression                 = 0x32,
    URKPackingMethodNormalCompression               = 0x33,
    URKPackingMethodGoodCompression                 = 0x34,
    URKPackingMethodBestCompression                 = 0x35
};

typedef NS_ENUM(NSUInteger, URKHostOS) {
    URKHostOSMSDOS                                 = 0,
    URKHostOSOS2                                   = 1,
    URKHostOSWindows                               = 2,
    URKHostOSUnix                                  = 3
};

@interface URKFileInfo : NSObject
@property (nonatomic, strong) NSString *archiveName;
@property (nonatomic, strong) NSString *fileName;
@property (nonatomic, strong) NSDate *fileTime;
@property (nonatomic, assign) long long unpackedSize;
@property (nonatomic, assign) long long packedSize;
@property (nonatomic, assign) URKFileFlags flags;
@property (nonatomic, assign) URKPackingMethod method;
@property (nonatomic, assign) URKHostOS hostOS;
@end

Then in the listFiles method we could map these header properties:

       // ...
        while ((RHCode = RARReadHeaderEx(_rarFile, header)) == 0) {
            URKFileInfo *file = [[URKFileInfo alloc] init];
            file.fileName = [NSString stringWithCString:header->FileName encoding:NSASCIIStringEncoding];
            file.archiveName = [NSString stringWithCString:header->ArcName encoding:NSASCIIStringEncoding];
            file.unpackedSize = (long long) header->UnpSizeHigh << 32 | header->UnpSize;
            file.packedSize = (long long) header->PackSizeHigh << 32 | header->PackSize;

This page and this page spells out some of the fields that could be pulled from the header. Things like Archive Name, FileName, PackedSize, UnpackedSize, Modify Date, CRC Hash.

An example use case for this is if you wanted to display detailed information about the rar archive contents, or let them selectively choose which files they would like to unarchive. The more file metadata I have, and can display about these files the better.

I have linker error after install UnrarKit via cocoapods.

I don't have another unrar library.
How to fix it?

Undefined symbols for architecture i386:
"std::bad_alloc::bad_alloc()", referenced from:
FragmentedWindow::Init(unsigned long) in libPods-UnrarKit.a(unpack.o)
Unpack::Init(unsigned long, bool) in libPods-UnrarKit.a(unpack.o)
"std::bad_alloc::~bad_alloc()", referenced from:
FragmentedWindow::Init(unsigned long) in libPods-UnrarKit.a(unpack.o)
Unpack::Init(unsigned long, bool) in libPods-UnrarKit.a(unpack.o)
"std::terminate()", referenced from:
___clang_call_terminate in libPods-UnrarKit.a(URKArchive.o)
___clang_call_terminate in libPods-UnrarKit.a(dll.o)
___clang_call_terminate in libPods-UnrarKit.a(secpassword.o)
___clang_call_terminate in libPods-UnrarKit.a(extract.o)
___clang_call_terminate in libPods-UnrarKit.a(options.o)
___clang_call_terminate in libPods-UnrarKit.a(strlist.o)
___clang_call_terminate in libPods-UnrarKit.a(cmddata.o)
...
"typeinfo for std::bad_alloc", referenced from:
GCC_except_table1 in libPods-UnrarKit.a(dll.o)
GCC_except_table19 in libPods-UnrarKit.a(dll.o)
FragmentedWindow::Init(unsigned long) in libPods-UnrarKit.a(unpack.o)
Unpack::Init(unsigned long, bool) in libPods-UnrarKit.a(unpack.o)
GCC_except_table1 in libPods-UnrarKit.a(dll.o)
GCC_except_table19 in libPods-UnrarKit.a(dll.o)
FragmentedWindow::Init(unsigned long) in libPods-UnrarKit.a(unpack.o)
Unpack::Init(unsigned long, bool) in libPods-UnrarKit.a(unpack.o)
"vtable for __cxxabiv1::__enum_type_info", referenced from:
typeinfo for RAR_EXIT in libPods-UnrarKit.a(dll.o)
typeinfo for RAR_EXIT in libPods-UnrarKit.a(errhnd.o)
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
"vtable for __cxxabiv1::__class_type_info", referenced from:
typeinfo for File in libPods-UnrarKit.a(file.o)
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
"vtable for cxxabiv1::si_class_type_info", referenced from:
typeinfo for Archive in libPods-UnrarKit.a(archive.o)
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
"operator delete", referenced from:
QuickOpen::~QuickOpen() in libPods-UnrarKit.a(qopen.o)
QuickOpen::Close() in libPods-UnrarKit.a(qopen.o)
RarVM::~RarVM() in libPods-UnrarKit.a(rarvm.o)
BitInput::~BitInput() in libPods-UnrarKit.a(getbits.o)
BitInput::SetExternalBuffer(unsigned char
) in libPods-UnrarKit.a(getbits.o)
"operator delete(void
)", referenced from:
-[URKArchive closeFile] in libPods-UnrarKit.a(URKArchive.o)
RAROpenArchiveEx in libPods-UnrarKit.a(dll.o)
RARCloseArchive in libPods-UnrarKit.a(dll.o)
CmdExtract::CmdExtract(CommandData
) in libPods-UnrarKit.a(extract.o)
CmdExtract::~CmdExtract() in libPods-UnrarKit.a(extract.o)
File::~File() in libPods-UnrarKit.a(file.o)
Archive::Archive(RAROptions
) in libPods-UnrarKit.a(archive.o)
...
"operator new[](unsigned long)", referenced from:
-[URKArchive unrarOpenFile:inMode:withPassword:error:] in libPods-UnrarKit.a(URKArchive.o)
QuickOpen::Init(Archive
, bool) in libPods-UnrarKit.a(qopen.o)
RarVM::Init() in libPods-UnrarKit.a(rarvm.o)
BitInput::BitInput(bool) in libPods-UnrarKit.a(getbits.o)
"operator new(unsigned long)", referenced from:
-[URKArchive unrarOpenFile:inMode:withPassword:error:] in libPods-UnrarKit.a(URKArchive.o)
RAROpenArchiveEx in libPods-UnrarKit.a(dll.o)
CmdExtract::CmdExtract(CommandData
) in libPods-UnrarKit.a(extract.o)
Archive::Archive(RAROptions
) in libPods-UnrarKit.a(archive.o)
Unpack::AddVMCode(unsigned int, unsigned char
, int) in libPods-UnrarKit.a(unpack.o)
ScanTree::FindProc(FindData
) in libPods-UnrarKit.a(scantree.o)
"___cxa_allocate_exception", referenced from:
ErrorHandler::Throw(RAR_EXIT) in libPods-UnrarKit.a(errhnd.o)
FragmentedWindow::Init(unsigned long) in libPods-UnrarKit.a(unpack.o)
Unpack::Init(unsigned long, bool) in libPods-UnrarKit.a(unpack.o)
"___cxa_begin_catch", referenced from:
clang_call_terminate in libPods-UnrarKit.a(URKArchive.o)
RAROpenArchiveEx in libPods-UnrarKit.a(dll.o)
RARReadHeaderEx in libPods-UnrarKit.a(dll.o)
ProcessFile(void
, int, char
, char
, wchar_t
, wchar_t
) in libPods-UnrarKit.a(dll.o)
___clang_call_terminate in libPods-UnrarKit.a(dll.o)
___clang_call_terminate in libPods-UnrarKit.a(secpassword.o)
___clang_call_terminate in libPods-UnrarKit.a(extract.o)
...
"_cxa_end_catch", referenced from:
RAROpenArchiveEx in libPods-UnrarKit.a(dll.o)
RARReadHeaderEx in libPods-UnrarKit.a(dll.o)
ProcessFile(void
, int, char
, char
, wchar_t
, wchar_t*) in libPods-UnrarKit.a(dll.o)
"___cxa_throw", referenced from:
ErrorHandler::Throw(RAR_EXIT) in libPods-UnrarKit.a(errhnd.o)
FragmentedWindow::Init(unsigned long) in libPods-UnrarKit.a(unpack.o)
Unpack::Init(unsigned long, bool) in libPods-UnrarKit.a(unpack.o)
"___gxx_personality_v0", referenced from:
Dwarf Exception Unwind Info (__eh_frame) in libPods-UnrarKit.a(URKArchive.o)
Dwarf Exception Unwind Info (__eh_frame) in libPods-UnrarKit.a(dll.o)
Dwarf Exception Unwind Info (__eh_frame) in libPods-UnrarKit.a(pathfn.o)
Dwarf Exception Unwind Info (__eh_frame) in libPods-UnrarKit.a(secpassword.o)
Dwarf Exception Unwind Info (__eh_frame) in libPods-UnrarKit.a(extract.o)
Dwarf Exception Unwind Info (__eh_frame) in libPods-UnrarKit.a(options.o)
Dwarf Exception Unwind Info (__eh_frame) in libPods-UnrarKit.a(strlist.o)
...
Dwarf Exception Unwind Info (__eh_frame) in libPods-UnrarKit.a(URKArchive.o)
Dwarf Exception Unwind Info (__eh_frame) in libPods-UnrarKit.a(dll.o)
Dwarf Exception Unwind Info (__eh_frame) in libPods-UnrarKit.a(pathfn.o)
Dwarf Exception Unwind Info (__eh_frame) in libPods-UnrarKit.a(secpassword.o)
Dwarf Exception Unwind Info (__eh_frame) in libPods-UnrarKit.a(extract.o)
Dwarf Exception Unwind Info (__eh_frame) in libPods-UnrarKit.a(options.o)
Dwarf Exception Unwind Info (__eh_frame) in libPods-UnrarKit.a(strlist.o)
...
Dwarf Exception Unwind Info (__eh_frame) in libPods-UnrarKit.a(URKArchive.o)
Dwarf Exception Unwind Info (__eh_frame) in libPods-UnrarKit.a(dll.o)
Dwarf Exception Unwind Info (__eh_frame) in libPods-UnrarKit.a(pathfn.o)
Dwarf Exception Unwind Info (__eh_frame) in libPods-UnrarKit.a(secpassword.o)
Dwarf Exception Unwind Info (__eh_frame) in libPods-UnrarKit.a(extract.o)
Dwarf Exception Unwind Info (__eh_frame) in libPods-UnrarKit.a(options.o)
Dwarf Exception Unwind Info (__eh_frame) in libPods-UnrarKit.a(strlist.o)
...
Dwarf Exception Unwind Info (__eh_frame) in libPods-UnrarKit.a(URKArchive.o)
Dwarf Exception Unwind Info (__eh_frame) in libPods-UnrarKit.a(dll.o)
Dwarf Exception Unwind Info (__eh_frame) in libPods-UnrarKit.a(pathfn.o)
Dwarf Exception Unwind Info (__eh_frame) in libPods-UnrarKit.a(secpassword.o)
Dwarf Exception Unwind Info (__eh_frame) in libPods-UnrarKit.a(extract.o)
Dwarf Exception Unwind Info (__eh_frame) in libPods-UnrarKit.a(options.o)
Dwarf Exception Unwind Info (__eh_frame) in libPods-UnrarKit.a(strlist.o)
...
Dwarf Exception Unwind Info (__eh_frame) in libPods-UnrarKit.a(URKArchive.o)
Dwarf Exception Unwind Info (__eh_frame) in libPods-UnrarKit.a(dll.o)
Dwarf Exception Unwind Info (__eh_frame) in libPods-UnrarKit.a(pathfn.o)
Dwarf Exception Unwind Info (__eh_frame) in libPods-UnrarKit.a(secpassword.o)
Dwarf Exception Unwind Info (__eh_frame) in libPods-UnrarKit.a(extract.o)
Dwarf Exception Unwind Info (__eh_frame) in libPods-UnrarKit.a(options.o)
Dwarf Exception Unwind Info (__eh_frame) in libPods-UnrarKit.a(strlist.o)
...
Dwarf Exception Unwind Info (__eh_frame) in libPods-UnrarKit.a(URKArchive.o)
Dwarf Exception Unwind Info (__eh_frame) in libPods-UnrarKit.a(dll.o)
Dwarf Exception Unwind Info (__eh_frame) in libPods-UnrarKit.a(pathfn.o)
Dwarf Exception Unwind Info (__eh_frame) in libPods-UnrarKit.a(secpassword.o)
Dwarf Exception Unwind Info (__eh_frame) in libPods-UnrarKit.a(extract.o)
Dwarf Exception Unwind Info (__eh_frame) in libPods-UnrarKit.a(options.o)
Dwarf Exception Unwind Info (__eh_frame) in libPods-UnrarKit.a(strlist.o)
...
Dwarf Exception Unwind Info (__eh_frame) in libPods-UnrarKit.a(URKArchive.o)
Dwarf Exception Unwind Info (__eh_frame) in libPods-UnrarKit.a(dll.o)
Dwarf Exception Unwind Info (__eh_frame) in libPods-UnrarKit.a(pathfn.o)
Dwarf Exception Unwind Info (__eh_frame) in libPods-UnrarKit.a(secpassword.o)
Dwarf Exception Unwind Info (__eh_frame) in libPods-UnrarKit.a(extract.o)
Dwarf Exception Unwind Info (__eh_frame) in libPods-UnrarKit.a(options.o)
Dwarf Exception Unwind Info (__eh_frame) in libPods-UnrarKit.a(strlist.o)
...
...
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Add isFolder property to URKFileInfo

Unless I'm missing something, I think right now there may be an issue if a user were to try and decompress an archive one file at a time due to not being able to tell if a URKFileInfo is a file or directory.

This edge case seems to only be an issue if you have empty directories. There is nothing to differentiate their filename from a file or folder (such as a trailing slash).

Here is an example archive:
https://dl.dropboxusercontent.com/u/638285/testrar.rar

It contains the following structure (note that URKFileInfo doesn't contain trailing slashes, they are here for demonstration only):

- testrar2/
- testrar2/testrar3/
- testfile

If I'm iterating through all the URKFileInfo objects, there will be 3 entries, and it is impossible for me to tell if testar2/testrar3 is a directory or a zero byte file (I think).

I believe that we can pull an isDirectory flag from the flags property of the RarReadHeaderEX, but I'm not entirely sure.

password protection check latency

hi,
please replace
int PFCode = RARProcessFile(_rarFile, RAR_SKIP, NULL, NULL);
instead of
int PFCode = RARProcessFile(_rarFile, RAR_TEST, NULL, NULL);
in (BOOL)isPasswordProtected
to speed up checking

Automatically push tagged successful builds to CocoaPods

As long as the build is for a tag, and there were no issues, push to CocoaPods. This link to Travis documentation and an answer to my question on Stack Overflow should provide enough info to do this.

It should only push if:

  1. All matrixed jobs have completed successfully

  2. The current build is tagged (TRAVIS_TAG var)

  3. The tag matches the podspec's version number

  4. The branch name is "master", or it's a pre-release build

    Turns out this isn't possible to check, since tag builds don't know their branch, only the tag name. Instead, validate that the tag looks like a version number (e.g. #.#.#(-beta#))

Steps:

  • Set up a branch to test this out
  • Update the Travis script in the branch with the changes above, set to echo instead of pushing to CocoaPods (this page provides the right way to go, until/unless CocoaPods gets fully supported by Travis)
  • Test that the echo runs
  • Test that any failures don't trigger the echo. Specifically:
  • a. Build failure
  • b. Test failure
  • c. Post-test validation failure
  • Get the configuration right, with API keys and so on
  • Replace the Podspec version number with $TRAVIS_TAG
  • Write a script to update the plist's version number's and tag the build
  • Clean up the various tags created during dev and testing
  • Push a test build
  • Add a script to push the release to GitHub
  • Move the updated .travis.yml and any scripts over to master

Unrar Operations leak file descriptors

Causes a leak for each call, meaning if you extract each file from an archive, there will be that many leaks. This can cause an app to run out of file descriptors in short order.

Fill hasMultipleVolumes on init

@property(atomic, readonly) BOOL hasMultipleVolumes;

Since the multivolume check is now done on init, I think this property should be filled there.
Also would be useful to have another property like "firstVolumeNotFound", also filled on init.

I can code it if you think like.

Add block-based API for working with archives, updating API to use URKFileInfo

Add the following methods:

- (void)performOnFilesInArchive:(void(^)(URKFileInfo *fileInfo, BOOL **stop))action
                          error:(NSError **)error;

- (void)performOnDataInArchive:(void(^)(URKFileInfo *fileInfo, NSData *fileData, BOOL **stop))action
                         error:(NSError **)error;

- (NSData *)extractDataFromFile:(URKFileInfo *) error:(NSError **)error;

Examples doesn't work

[!] Unable to find a target named Demo
[!] Unable to find a target named DemoTests

Some URKLogInfo that might be URKLogDebug

Should those be URKLogDebug instead of URKLogInfo?

URKLogInfo("Reading through RAR header looking for files...");

URKLogInfo("Reading through RAR header looking for files...");

URKLogInfo("Reading through RAR header looking for files...");

URKLogInfo("Reading through RAR header looking for files...");

Files read with 0 length when file moved during read

Steps to reproduce

  1. Begin extracting the contents of an archive
  2. Move the file to a different directory before finishing extraction

Expected

Best case: the extraction seamlessly completes
Next best: file move is blocked, so the file can't be moved until UnrarKit is done with it
Last resort: Return an error code.

If the archive is deleted during extraction (via, say, an rm in Terminal, since moving to the Trash is just a file move as described above), an error should be returned (a distinct code from the one defined in the "last resort" case.

Actual

As soon as the file is moved, 0 bytes are returned for the remainder of the file that was in progress, and for the entirety of the remaining files.

"FileNotFound" problem with Unicode characters in iOS 10.3 with APFS FileSystem

Hi,
After released iOS 10.3 update with the change of FileSystem from HFS+ to APFS, most of filename with Unicode characters are can't unzip. (Before this update, all things are work perfectly)

Based on Apple, to avoid the problem, try to "Use the fileSystemRepresentation property of NSURL objects when creating and opening files with lower-level filesystem APIs such as POSIX open(2), or when storing filenames externally from the filesystem".

I have digged into UnrarKit library and have tried alot but unsuccessful, can you help me with this problem.
Thank you very much!

(Detail problem link: https://eclecticlight.co/2017/04/06/apfs-is-currently-unusable-with-most-non-english-languages/)
(Zip file link: https://www.dropbox.com/s/hhtoxqixj24dejb/QR%E3%82%B3%E3%83%BC%E3%83%89.zip?dl=0)

Consolidate targets across platforms

I recently discovered the "Supported Platforms" build setting. I should use that to make a single cross-platform framework and unit test bundle. This will make the project easier to maintain going forward.

  • Update project's supported platforms
  • Make UnrarKit target support all platforms
  • Once everything's working right for macOS and iOS with the unified targets, drop the iOS-specific targets

NSLog fallback prints all messages even on release

At least for release, all non URKLogError or URKLogFault messages should be optional. Even those, since the functions printing this messages also return the NSErrorobject.

Maybe I'm missing something.

NSErrors returned misuse the NSUnderlyingError userInfo key

It should contain an NSError* object, not a string, as it currently does. Use a different key, like NSLocalizedFailureReasonErrorKey, and bump the minor revision number, since this might break someone who's looking for the existing key.

Add support for NSProgress

Make URKArchive implement NSProgressReporting on OS X >= 10.11 and iOS >= 9.0, and support implicit progress reporting for earlier OSes.

https://developer.apple.com/videos/play/wwdc2015/232/

Remaining tasks:

  • Add NSProgress support to all top-level methods
  • For extraction to disk, add passing of the current file info to NSProgress
  • Add section to Readme describing sample NSProgress usage and cancellation
  • Deprecate the methods that use a progressBlock argument, mentioning migration to NSProgress
  • Update documentation

Unfork UnrarKit from Unrar4iOS

I think that UnrarKit should try to see if it is possible to "unfork" it's repo from Unrar4iOS. Some reasons for this change would be:

  • UnrarKit has become a project onto it's own. The two codebases have diverged greatly and are unlikely to join paths again.
  • GitHub restricts certain features from forked repos (such as repo search)
  • Contributors looking to submit PRs to UnrarKit must always put up with their pull requests defaulting to the master repo (Unrar4iOS). This is confusing and has already lead to me almost submitting a PR to the wrong repo.

validatePassword not working with RAR5

Hello,

The method validatePassword don't work if the archive is RAR5.

You can test using this archive (password is 123):
https://www.dropbox.com/s/rnl6y9jons1eiyp/rar5WithPassword.rar?dl=0

This happens because this if

if (RHCode == ERAR_MISSING_PASSWORD || PFCode == ERAR_MISSING_PASSWORD || RHCode == ERAR_BAD_DATA || PFCode == ERAR_BAD_DATA)
            return;

is not checking if PFCode is ERAR_BAD_PASSWORD, which is the value a rar5 with wrong password returns. So, change this if to ->

if (RHCode == ERAR_MISSING_PASSWORD || PFCode == ERAR_BAD_PASSWORD || PFCode == ERAR_MISSING_PASSWORD || RHCode == ERAR_BAD_DATA || PFCode == ERAR_BAD_DATA)
            return;

to fix this issue =).

Compile with -Weverything flag

This produces a ton of warnings, but the problem is I don't want any warnings reported for the unrar library. I can solve this by moving the unrar library into its own static library that'll get compiled in, I think. Then I'll specify -Weverything for UnrarKit, and -Wnone for unrar. This makes sense after #55, since it involves changing target configuration around.

  • Split unrar into its own library, linked into UnrarKit
  • Specify -Weverything for UnrarKit
  • Fix all warnings produced

Reduce repo size

It should be under 10 MB, since it's getting dinged by the CocoaPods quality check. The culprits are two CBR files stored with the example project, which can be dumped altogether, and the Large Archive file used for testing, which can possibly be generated as part of the unit test.

Example doesn't run on device (only simulator)

Works in simulator, doesn't work on real device. The strangest thing is it is "compiled successfully" but the app is not installed on the device. Log:

dyld: Library not loaded: @rpath/UnrarKit.framework/UnrarKit
Referenced from: /var/mobile/Containers/Bundle/Application/0FEBCED9-848A-4262-9399-7AA060C61F3E/UnrarExample.app/UnrarExample
Reason: image not found

ExtractData methods not attributed with nullable

extractData:progress:error: and -extractDataFromFile:progress:error: are missing the nullable attribute, even though they return nil for error conditions. This should be especially helpful for Swift users.

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.