Skip to content

Commit

Permalink
Release 0.0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
OlehKulykov committed Nov 24, 2015
1 parent 6d2d4ab commit 281eae9
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 29 deletions.
9 changes: 6 additions & 3 deletions src/LzmaSDKObjC.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,15 @@
/*
* Lzma SDK for Objective-C based on extended functionality of the C++ LZMA code
*
* Changes on version 0.0.8 (current):
* Changes on version 0.0.9 (current):
* - Extract empty archive folders
*
* Changes on version 0.0.8:
* - Update LZMA SDK to version 15.12.
* Note: If you use XZ code from LZMA SDK, it's recommended to upgrade to new XZ code from 7-Zip 15.12.
* That new code fixes some bugs.
*
* Changes on version 0.0.7 (current):
* Changes on version 0.0.7:
* - Enabled test functionality.
*
* Changes on version 0.0.6:
Expand Down Expand Up @@ -63,7 +66,7 @@

#define LZMASDKOBJC_VERSION_MAJOR 0
#define LZMASDKOBJC_VERSION_MINOR 0
#define LZMASDKOBJC_VERSION_PATCH 8
#define LZMASDKOBJC_VERSION_PATCH 9


#include "LzmaSDKObjCTypes.h"
Expand Down
20 changes: 18 additions & 2 deletions src/LzmaSDKObjCCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,32 @@ uint64_t LzmaSDKObjCPROPVARIANTGetUInt64(PROPVARIANT * prop)
switch (prop->vt)
{
case VT_UI8: return prop->uhVal.QuadPart;
case VT_UI4: return prop->ulVal;

case VT_HRESULT:
case VT_UI4:
return prop->ulVal;

case VT_UINT: return prop->uintVal;
case VT_I8: return prop->hVal.QuadPart;
case VT_UI1: return prop->bVal;
case VT_I4: return prop->lVal;
default:break;
case VT_INT: return prop->intVal;

default: break;
}
return 0;
}

bool LzmaSDKObjCPROPVARIANTGetBool(PROPVARIANT * prop)
{
switch (prop->vt)
{
case VT_BOOL: return (prop->boolVal == 0) ? false : true;
default: break;
}
return (LzmaSDKObjCPROPVARIANTGetUInt64(prop) == 0) ? false : true;
}

time_t LzmaSDKObjCFILETIMEToUnixTime(const FILETIME filetime)
{
long long int t = filetime.dwHighDateTime;
Expand Down
2 changes: 2 additions & 0 deletions src/LzmaSDKObjCCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ LZMASDKOBJC_EXTERN const GUID LzmaSDKObjCCLSIDFormatXz;

LZMASDKOBJC_EXTERN uint64_t LzmaSDKObjCPROPVARIANTGetUInt64(PROPVARIANT * prop);

LZMASDKOBJC_EXTERN bool LzmaSDKObjCPROPVARIANTGetBool(PROPVARIANT * prop);

LZMASDKOBJC_EXTERN time_t LzmaSDKObjCFILETIMEToUnixTime(const FILETIME filetime);

#endif
54 changes: 32 additions & 22 deletions src/LzmaSDKObjCExtractCallback.mm
Original file line number Diff line number Diff line change
Expand Up @@ -139,25 +139,45 @@

fullPath = [fullPath stringByAppendingPathComponent:fileName];

LzmaSDKObjC::OutFile * outFile = new LzmaSDKObjC::OutFile();
if (!outFile)
PROPVARIANT isDirProp;
HRESULT res = _archive->GetProperty(index, kpidIsDir, &isDirProp);
if (res != S_OK)
{
this->setLastError(E_ABORT, __LINE__, __FILE__, "Can't create out file stream");
return E_ABORT;
this->setLastError(res, __LINE__, __FILE__, "Can't get property of the item by index: %u", (unsigned int)index);
return res;
}

if (!outFile->open([fullPath UTF8String]))
if (LzmaSDKObjCPROPVARIANTGetBool(&isDirProp))
{
delete outFile;
this->setLastError(E_ABORT, __LINE__, __FILE__, "Can't open destination for write: [%s]", [fullPath UTF8String]);
return E_ABORT;
NSError * error = nil;
if (![[NSFileManager defaultManager] createDirectoryAtPath:fullPath withIntermediateDirectories:YES attributes:nil error:&error] || error)
{
this->setLastError(S_FALSE, __LINE__, __FILE__, "Can't create directory: [%s]", [fullPath UTF8String]);
return E_ABORT;
}
}
else
{
LzmaSDKObjC::OutFile * outFile = new LzmaSDKObjC::OutFile();
if (!outFile)
{
this->setLastError(E_ABORT, __LINE__, __FILE__, "Can't create out file stream");
return E_ABORT;
}

_outFileStreamRef = outFile;
CMyComPtr<ISequentialOutStream> outStreamLoc = _outFileStreamRef;
if (!outFile->open([fullPath UTF8String]))
{
delete outFile;
this->setLastError(E_ABORT, __LINE__, __FILE__, "Can't open destination for write: [%s]", [fullPath UTF8String]);
return E_ABORT;
}

_outFileStream = outStreamLoc;
*outStream = outStreamLoc.Detach();
_outFileStreamRef = outFile;
CMyComPtr<ISequentialOutStream> outStreamLoc = _outFileStreamRef;

_outFileStream = outStreamLoc;
*outStream = outStreamLoc.Detach();
}

return S_OK;
}
Expand All @@ -176,16 +196,6 @@
return E_ABORT;
}

PROPVARIANT isDirProp;
HRESULT res = _archive->GetProperty(index, kpidIsDir, &isDirProp);
if (res != S_OK)
{
this->setLastError(res, __LINE__, __FILE__, "Can't get property of the item by index: %u", (unsigned int)index);
return res;
}

if (isDirProp.vt != VT_BOOL || isDirProp.boolVal) return S_OK;

switch (_mode)
{
case NArchive::NExtract::NAskMode::kExtract:
Expand Down
2 changes: 1 addition & 1 deletion src/LzmaSDKObjCReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ LZMASDKOBJC_EXTERN NSString * const _Nonnull kLzmaSDKObjCErrorDomain;
*/
- (BOOL) extract:(nullable NSArray<LzmaSDKObjCItem *> *) items
toPath:(nullable NSString *) path
withFullPaths:(BOOL) isFullPaths;
withFullPaths:(BOOL) isFullPaths;


/**
Expand Down
2 changes: 1 addition & 1 deletion tests/ios/ios/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ - (IBAction) on1:(id)sender


NSString * archivePath = [@"/Volumes/Data/Documents/LzmaSDK-ObjC/tests/files/" stringByAppendingPathComponent:testFile];
// archivePath = @"/Volumes/Data/1/example.7Z";
// archivePath = @"/Volumes/Data/1/2.7z";

self.reader = [[LzmaSDKObjCReader alloc] initWithFileURL:[NSURL fileURLWithPath:archivePath]];

Expand Down

0 comments on commit 281eae9

Please sign in to comment.