olehkulykov / plzmasdk Goto Github PK
View Code? Open in Web Editor NEWPLzmaSDK is (Portable, Patched, Package, cross-P-latform) Lzma SDK.
License: Other
PLzmaSDK is (Portable, Patched, Package, cross-P-latform) Lzma SDK.
License: Other
Hi!
File's creation and modified dates are wring and set to decompressed date so each decompressing iteration gives the different creation and modified date. How to get original creation and modified date of the decompressed files?
I decompress files as
plzma_decoder_extract_all_items_to_path(&decoder, &pathObject, itemsFullPath)
then I read dates from files attributes
try fileManager.attributesOfItem(atPath: path.path)
I imported the Swift package using the git url -
https://github.com/OlehKulykov/PLzmaSDK.git
I get this build error -
The package product 'PLzmaSDK-Static' cannot be used as a dependency of this target because it uses unsafe build flags.
Xcode 12.4 and Catalina 10.15.7
I found that README mentioned the PLzmaSDK support 7z multivolume archives, but I don't know how to implement it. Can you give me some guidance
I used the method in the demo to set the password and compressed it successfully. But when I uncompressed the file, I did not need to enter a password to uncompress it.
When I unzip a 7z file, PLzmaSDK takes about 20s, LzmaSDKObjC takes about 6s, why?
How can i detect a password protected file ?
Can you suggest a way to handle the password protected files. The exception description says "can't open in archive".
I am extracting the file and checking that, if it is not getting extracted then displaying a "enter password" prompt. But if it is not getting extracted for some other reason , then how can i know ?
Any API available for Password Protected files other than setPassword() ?
Hi,
Thanks for this library! I was using LzmaSDKObjC then migrated to PLzmaSDK since I was looking for SPM support (and because you deprecated the first one).
I'm now encountering a crash on a few 7z extraction, it's a bit random: some passes, others doesn't, but it's always the same stack.
Here a screenshot of the crash and the output using bt
in Xcode:
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x8)
* frame #0: 0x00000001111f4c9c MyFramework`plzma::RawHeapMemory::operator bool<bool>(this=0x0000000000000008) at libplzma.hpp:80:63
frame #1: 0x00000001111fb8e6 MyFramework`plzma::String::utf8(this=0x0000000000000000) const at plzma_string.cpp:121:14
frame #2: 0x00000001111f9da5 MyFramework`plzma::Progress::ReportData::report(this=0x00007ffedff23c68) const at plzma_progress.hpp:70:49
frame #3: 0x00000001111fa15c MyFramework`plzma::Progress::setCompleted(this=0x0000600001ab1a40, completed=86154) at plzma_progress.cpp:151:20
frame #4: 0x00000001111d901a MyFramework`plzma::BaseCallback::setProgressCompleted(this=0x00007ff694d0c000, completed=86154) at plzma_base_callback.cpp:94:28
frame #5: 0x00000001111e895c MyFramework`plzma::ExtractCallback::SetCompleted(this=0x00007ff694d0c000, completeValue=0x00007ffedff23da0) at plzma_extract_callback.cpp:66:32
frame #6: 0x00000001111af4e2 MyFramework`CLocalProgress::SetRatioInfo(this=0x0000600000815090, inSize=0x00007ffedff23e18, outSize=0x00007ff69ac5eae0) at ProgressUtils.cpp:42:23
frame #7: 0x00000001111bc3ac MyFramework`NCompress::NLzma::CDecoder::CodeSpec(this=0x00007ff69ac5ea70, inStream=0x000060000257cfc0, outStream=0x00006000008163a0, progress=0x0000600000815090) at LzmaDecoder.cpp:207:7
frame #8: 0x00000001111bc454 MyFramework`NCompress::NLzma::CDecoder::Code(this=0x00007ff69ac5ea70, inStream=0x000060000257cfc0, outStream=0x00006000008163a0, inSize=0x000060000298d330, outSize=0x0000600000834d88, progress=0x0000600000815090) at LzmaDecoder.cpp:219:17
frame #9: 0x0000000111189891 MyFramework`NCoderMixer2::CMixerST::Code(this=0x0000600001e827c0, inStreams=0x000060000298d380, outStreams=0x00007ffedff24608, progress=0x0000600000815090, dataAfterEnd_Error=0x00007ffedff24a7f) at CoderMixer2.cpp:776:28
frame #10: 0x0000000111157c1b MyFramework`NArchive::N7z::CDecoder::Decode(this=0x00007ffedff24af0, inStream=0x0000600000562400, startPos=32, folders=0x00007ff694e2c4b8, folderIndex=0, unpackSize=0x00007ffedff24ae0, outStream=0x00006000008163a0, compressProgress=0x0000600000815090, inStreamMainRes=0x0000000000000000, dataAfterEnd_Error=0x00007ffedff24a7f, getTextPassword=0x00007ff694d0c000, isEncrypted=0x00007ffedff24a97, passwordIsDefined=0x00007ffedff24a96, password=0x00007ffedff24a80) at 7zDecode.cpp:557:20
frame #11: 0x000000011116396f MyFramework`NArchive::N7z::CHandler::Extract(this=0x00007ff694e2c400, indices=0x00007ffedff24d40, numItems=16, testModeSpec=0, extractCallbackSpec=0x00007ff694d0c000) at 7zExtract.cpp:359:32
frame #12: 0x00000001111ea80a MyFramework`plzma::ExtractCallback::process(this=0x00007ff694d0c000) at plzma_extract_callback.cpp:339:67
frame #13: 0x00000001111eac52 MyFramework`plzma::ExtractCallback::process(this=0x00007ff694d0c000, mode=0, path=0x0000600002bcb720, itemsFullPath=true) at plzma_extract_callback.cpp:376:9
frame #14: 0x00000001111da946 MyFramework`bool plzma::DecoderImpl::process<NArchive::NExtract::NAskMode::$_0, plzma::Path const&, bool const&>(this=0x0000600001ab1860, args=0x00007ffedff25278, args=0x0000600002bcb720, args=0x00007ffedff2527f) at plzma_decoder_impl.hpp:87:30
frame #15: 0x00000001111da762 MyFramework`plzma::DecoderImpl::extract(this=0x0000600001ab1860, path=0x0000600002bcb720, usingItemsFullPath=true) at plzma_decoder_impl.cpp:91:16
frame #16: 0x00000001111dd1e9 MyFramework`::plzma_decoder_extract_all_items_to_path(decoder=0x00007ffedff253c0, path=0x00007ffedff253b0, items_full_path=true) at plzma_decoder_impl.cpp:268:57
frame #17: 0x000000011110be7f MyFramework`Decoder.extract(path=0x0000600002bcbc80, itemsFullPath=true, self=0x0000600002b02560) at Decoder.swift:143:22
frame #18: 0x00000001110de69e MyFramework`KitDownloader.extractArchive(archivePath="/Users/user/Library/Developer/CoreSimulator/Devices/DED1A430-584D-4171-B485-1AD70264556F/data/Containers/Data/Application/2EB1C261-43AA-4A0C-8BA9-3F26B74CDD71/Documents/JamPacks/id/jam.7z", completion=0x00000001110e2020 MyFramework`partial apply forwarder for closure #1 () -> () in KitDownloaderCommon.KitDownloader.(extractJam in _FF877985CBDE0E1D4F887358C8775D0F)(at: Foundation.URL) -> () at <compiler-generated>, self=0x0000600001abe1c0) at KitDownloader.swift:192:25
frame #19: 0x00000001110dd596 MyFramework`KitDownloader.extractJam(location=<unavailable; try printing with "vo" or "po">, self=0x0000600001abe1c0) at KitDownloader.swift:172:17
frame #20: 0x00000001110dd30b MyFramework`closure #2 in KitDownloader.downloadArchive(result=<invalid> (0x80), self=0x0000600001abe1c0) at KitDownloader.swift:151:22
frame #21: 0x000000011110456b MyFramework`closure #1 in DownloadDriver.completeRequest(meta=0x00006000031a2440, result=<invalid> (0x80)) at DownloadDriver.swift:105:18
frame #22: 0x0000000111103250 MyFramework`thunk for @escaping @callee_guaranteed () -> () at <compiler-generated>:0
frame #23: 0x0000000115d597ec libdispatch.dylib`_dispatch_call_block_and_release + 12
frame #24: 0x0000000115d5a9c8 libdispatch.dylib`_dispatch_client_callout + 8
frame #25: 0x0000000115d68e75 libdispatch.dylib`_dispatch_main_queue_callback_4CF + 1152
frame #26: 0x00007fff2038edbb CoreFoundation`__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
frame #27: 0x00007fff2038963e CoreFoundation`__CFRunLoopRun + 2685
frame #28: 0x00007fff203886d6 CoreFoundation`CFRunLoopRunSpecific + 567
frame #29: 0x00007fff2bededb3 GraphicsServices`GSEventRunModal + 139
frame #30: 0x00007fff24690e0b UIKitCore`-[UIApplication _run] + 912
frame #31: 0x00007fff24695cbc UIKitCore`UIApplicationMain + 101
frame #32: 0x000000010fe00b68 MyApp`main at AppDelegate.swift:7:7
frame #33: 0x00007fff202593e9 libdyld.dylib`start + 1
and here how we use PLzmaSDK
, it's more or less what you put in the README:
let archivePath = try Path(archivePath)
let archivePathInStream = try InStream(path: archivePath)
let decoder = try Decoder(stream: archivePathInStream, fileType: .sevenZ, delegate: self)
let password = "..."
try decoder.setPassword(password)
_ = try decoder.open()
let outputPath = ...
_ = try decoder.extract(to: Path(outputPath))
Since the archive has sensible data I can't share it here, but what can I add to help you identify the issue? Did I miss something?
Using Swift 1.1.3 version, I get this crash decoding an archive. Note that the MacOS finder opens the archive correctly, the old LzmaSDKObjC opened it as well, although it was missing some files.
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = Fatal error: Unexpectedly found nil while unwrapping an Optional value
frame #0: 0x00000001ad10bd84 libswiftCore.dylib`_swift_runtime_on_report
frame #1: 0x00000001ad184de8 libswiftCore.dylib`_swift_stdlib_reportFatalErrorInFile + 192
frame #2: 0x00000001acdc0a0c libswiftCore.dylib`closure #1 (Swift.UnsafeBufferPointer<Swift.UInt8>) -> () in closure #1 (Swift.UnsafeBufferPointer<Swift.UInt8>) -> () in closure #1 (Swift.UnsafeBufferPointer<Swift.UInt8>) -> () in Swift._assertionFailure(_: Swift.StaticString, _: Swift.StaticString, file: Swift.StaticString, line: Swift.UInt, flags: Swift.UInt32) -> Swift.Never + 404
frame #3: 0x00000001acdc0048 libswiftCore.dylib`Swift._assertionFailure(_: Swift.StaticString, _: Swift.StaticString, file: Swift.StaticString, line: Swift.UInt, flags: Swift.UInt32) -> Swift.Never + 396
* frame #4: 0x000000010508d314 PLzmaSDK-Dynamic`String.init(ptr=0x6000033c2850) at String+Plzma.swift:34:53
frame #5: 0x000000010507b318 PLzmaSDK-Dynamic`closure #2 in Decoder.init(ctx=0x600000166e80, utf8CString=0x6000033c2850, progress=0x3fd9bbd30c4b7e1c) at Decoder.swift:280:58
frame #6: 0x000000010507b38c PLzmaSDK-Dynamic`@objc closure #2 in Decoder.init(stream:fileType:delegate:) at <compiler-generated>:0
frame #7: 0x000000010515a6f4 PLzmaSDK-Dynamic`plzma::Progress::ReportData::report(this=0x000000016d69fa28) const at plzma_progress.hpp:63:21
frame #8: 0x000000010515ace4 PLzmaSDK-Dynamic`plzma::Progress::setPath(this=0x00006000039ba640, path=0x000000016d69fcc0) at plzma_progress.cpp:173:20
frame #9: 0x00000001051455b4 PLzmaSDK-Dynamic`plzma::ExtractCallback::getExtractStream(this=0x000000012de94700, index=28, outStream=0x000000016d69fe30) at plzma_extract_callback.cpp:187:20
frame #10: 0x0000000105145930 PLzmaSDK-Dynamic`plzma::ExtractCallback::GetStream(this=0x000000012de94700, index=28, outStream=0x000000016d69fe30, askExtractMode=0) at plzma_extract_callback.cpp:208:42
frame #11: 0x00000001050ca168 PLzmaSDK-Dynamic`NArchive::N7z::CFolderOutStream::OpenFile(this=0x0000600002fecb90, isCorrupted=false) at 7zExtract.cpp:93:3
frame #12: 0x00000001050ca790 PLzmaSDK-Dynamic`NArchive::N7z::CFolderOutStream::Write(this=0x0000600002fecb90, data=0x00000002c5fa8407, size=130169, processedSize=0x000000016d69ff08) at 7zExtract.cpp:195:5
frame #13: 0x000000010510f3cc PLzmaSDK-Dynamic`WriteStream(stream=0x0000600002fecb90, data=0x00000002c5bc8080, size=4194304) at StreamUtils.cpp:48:27
frame #14: 0x00000001051026a4 PLzmaSDK-Dynamic`MyWrite(pp=0x000000016d6a0188, data=0x00000002c5bc8080, size=4194304) at CWrappers.cpp:93:14
frame #15: 0x00000001050a25d8 PLzmaSDK-Dynamic`Lzma2Dec_Decode_ST(p=0x000000011a5b7a80) at Lzma2DecMt.c:748:26
frame #16: 0x00000001050a2210 PLzmaSDK-Dynamic`Lzma2DecMt_Decode(pp=0x000000011a5b7a80, prop='\x1c', props=0x000000016d6a01c8, outStream=0x000000016d6a0188, outDataSize=0x0000600002fe9378, finishMode=1, inStream=0x000000016d6a01a8, inProcessed=0x000000016d6a0160, isMT=0x000000016d6a015c, progress=0x000000016d6a0170) at Lzma2DecMt.c:949:16
frame #17: 0x0000000105116b5c PLzmaSDK-Dynamic`NCompress::NLzma2::CDecoder::Code(this=0x0000600003e71050, inStream=0x0000600000165fb0, outStream=0x0000600002fecb90, inSize=0x0000600000eefd90, outSize=0x0000600002fe9378, progress=0x0000600002fefca0) at Lzma2Decoder.cpp:152:9
frame #18: 0x00000001050ec134 PLzmaSDK-Dynamic`NCoderMixer2::CMixerST::Code(this=0x00006000039b8780, inStreams=0x0000600000eec660, outStreams=0x000000016d6a0850, progress=0x0000600002fefca0, dataAfterEnd_Error=0x000000016d6a0c9f) at CoderMixer2.cpp:776:28
frame #19: 0x00000001050c0654 PLzmaSDK-Dynamic`NArchive::N7z::CDecoder::Decode(this=0x000000016d6a0d10, inStream=0x00006000023fcb00, startPos=32, folders=0x000000011a5c69c8, folderIndex=0, unpackSize=0x000000016d6a0d00, outStream=0x0000600002fecb90, compressProgress=0x0000600002fefca0, inStreamMainRes=0x0000000000000000, dataAfterEnd_Error=0x000000016d6a0c9f, getTextPassword=0x000000012de94700, isEncrypted=0x000000016d6a0cb7, passwordIsDefined=0x000000016d6a0cb6, password=0x000000016d6a0ca0) at 7zDecode.cpp:557:20
frame #20: 0x00000001050cafe8 PLzmaSDK-Dynamic`NArchive::N7z::CHandler::Extract(this=0x000000011a5c6910, indices=0x000000016d6a0f58, numItems=63, testModeSpec=0, extractCallbackSpec=0x000000012de94700) at 7zExtract.cpp:359:32
frame #21: 0x00000001051462c4 PLzmaSDK-Dynamic`plzma::ExtractCallback::process(this=0x000000012de94700) at plzma_extract_callback.cpp:356:67
frame #22: 0x0000000105146640 PLzmaSDK-Dynamic`plzma::ExtractCallback::process(this=0x000000012de94700, mode=0, path=0x0000600000d20020, itemsFullPath=true) at plzma_extract_callback.cpp:395:9
frame #23: 0x0000000105137608 PLzmaSDK-Dynamic`bool plzma::DecoderImpl::process<NArchive::NExtract::NAskMode::$_0, plzma::Path const&, bool const&>(this=0x0000600003a5c280, args=0x000000016d6a1488, args=0x0000600000d20020, args=0x000000016d6a148f) at plzma_decoder_impl.hpp:104:30
frame #24: 0x00000001051374a0 PLzmaSDK-Dynamic`plzma::DecoderImpl::extract(this=0x0000600003a5c280, path=0x0000600000d20020, usingItemsFullPath=true) at plzma_decoder_impl.cpp:105:16
frame #25: 0x0000000105139b24 PLzmaSDK-Dynamic`::plzma_decoder_extract_all_items_to_path(decoder=0x000000016d6a1578, path=0x000000016d6a1568, items_full_path=true) at plzma_decoder_impl.cpp:290:57
frame #26: 0x0000000105079f24 PLzmaSDK-Dynamic`Decoder.extract(path=0x0000600000d22cc0, itemsFullPath=true, self=0x0000600000d23940) at Decoder.swift:142:22
I read docs here only this line
cd <PATH_TO_ANDROID_NDK>./ndk-build NDK_PROJECT_PATH=<PATH_TO_PLZMASDK>/PLzmaSDK/android
for android ? please add a detailed demo i don't know how to use the library with android kotlin.
I was assessing PLzmaSDK to see if it could be useful for my Swift based project which uses a protocol to abstract over (stream) compression implementations, a bit like this:
protocol DeflateProtocol {
func append (_ buffer: Data) -> Data
func finalize () -> Data
}
Possible solutions that I can see for PLzmaSDK to support this kind of interface:
InStream.init(stream:)
public, so I can do all the dirty work mapping back and forth between @convention(c)
and Swift callbacks.InStream
accepting Swift callbacks.Which of these sounds more acceptable for the PLzmaSDK project?
I found macro '_NO_CRYPTO', can you open it?
There is a problem with the progress of the 7z decompression. The progress only shows 0%, 50%,100% during the decompression process
Hi 👋
I am using this library to decompress some selected files that have a specific prefix from an archive. I an doing it from inside a Widget extension, in iOS. The total decompressed size of the files to decompress is 4MB, the decompressed archive is 120MB, and the archive itself is 10MB. The decompression code is as follows:
func decompress(prefix: String, from archiveUrl: URL, to outputUrl: URL) throws {
let archivePath = try Path(archiveUrl.path)
let archivePathInStream = try InStream(path: archivePath)
let decoder = try Decoder(stream: archivePathInStream, fileType: .sevenZ, delegate: self)
guard try decoder.open() else {
throw PLzmaServiceError.couldNotOpenDecoder
}
let numberOfArchiveItems = try decoder.count()
let selectedItemsDuringIteration = try ItemArray(capacity: numberOfArchiveItems)
for itemIndex in 0..<numberOfArchiveItems {
let item = try decoder.item(at: itemIndex)
let path = try String(describing: item.path())
if path.hasPrefix("\(prefix)/") {
try selectedItemsDuringIteration.add(item: item)
}
}
let extracted = try decoder.extract(
items: selectedItemsDuringIteration,
to: try Path(outputUrl.path)
)
guard extracted else {
throw PLzmaServiceError.couldNotExtract
}
}
During that operations I get a runtime exception saying EXC_RESOURCE (RESOURCE_TYPE_MEMORY: high watermark memory limit exceeded) (limit=30 MB)
. Seems like the Widget extension has some memory limits enforced by iOS, and the decompression is exceeding them. As a result, the OS kills the process in the middle of the decompression operation.
Is there any way to configure the decompression so it uses less memory?
Thanks!
Hi, android ndk-build failed:
jni/../../src/CPP/7zip/Common/FileStreams.cpp:554:27: error: use of undeclared identifier 'major'
prop = (UInt32)(major(st.st_rdev)); // + 1000);
^
jni/../../src/CPP/7zip/Common/FileStreams.cpp:562:27: error: use of undeclared identifier 'minor'
prop = (UInt32)(minor(st.st_rdev)); // + 100);
^
2 errors generated.
I've tried plzmaSDK 1.2.2 and 1.2.3. And tried with several ndk-version,
Did I miss something?
I use LzmaSDK Extracting 7z files takes 5 seconds, while using PLzmaSDK takes 31 seconds!
Does this sdk support 7z multi-volume archives on the mobile devices?
hope receive you feedback
Hi,
Is there a plan to include the PrivacyInfo.xcprivacy manifest as required by Apple?
Reference to Apple docs: https://developer.apple.com/documentation/bundleresources/privacy_manifest_files
Thanks,
Karthik
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.