Comments (4)
The solution was found. It's just that after each Attach() call, you need to call Detach(). I think this is obvious, but I didn't immediately guess.
from p7zip.
Can you post your code? I can't open the picture. @Kitsune2222
from p7zip.
In my project need call IInArchive methods from different places (I'm wan't write Kotlin JNI binding for this library, for android). Me need store IInArchive pointer for opened archive, and i'm get it by Detach(). When me need IInArchive i'm get it by this saved pointer.
It not real, short, stupid code which cause this problem. It archive2->Extract() function not working when (archive1 and archive2) are in different methods which called from JNI:
CMyComPtr<IInArchive> archive;
CCodecs *c = new CCodecs;
HRESULT res = c->Load();
HRESULT res2 = c->CreateInArchive(archiveFormat, archive);
UInt64 maxPos = 4 * 1024 * 1024;
archive->Open(iStream, &maxPos, nullptr);
size_t pointer = (size_t) (void *) archive.Detach();
// Method 1 (Get number of items)
CMyComPtr<IInArchive> archive1;
archive1.Attach((IInArchive *) pointer);
UInt32 numItems;
archive1->GetNumberOfItems(&numItems);
// Method 2 (Extract)
CMyComPtr<IInArchive> archive2;
archive2.Attach((IInArchive *) pointer);
archive2->Extract((UInt32 *) 0, (UInt32) -1, false, nullptr);
It's weird but when they are in the same function, it works now (Checked now). Doesn't work in different methods which called by JNI.
It working always:
CMyComPtr<IInArchive> archive;
CCodecs *c = new CCodecs;
HRESULT res = c->Load();
HRESULT res2 = c->CreateInArchive(archiveFormat, archive);
UInt64 maxPos = 4 * 1024 * 1024;
archive->Open(iStream, &maxPos, nullptr);
size_t pointer = (size_t) (void *) archive.Detach();
// Method 1 (Get number of items)
CMyComPtr<IInArchive> archive1;
archive1.Attach((IInArchive *) pointer);
UInt32 numItems;
archive1->GetNumberOfItems(&numItems);
archive1.Detach();
// Method 2 (Extract)
CMyComPtr<IInArchive> archive2;
archive2.Attach((IInArchive *) pointer);
archive2->Extract((UInt32 *) 0, (UInt32) -1, false, nullptr);
archive2.Detach();
I don't know how to do it right, but second variant works. What do you say about this?
P.s. nullptr in callbacks it's temporarily code, i'm know.
Upd.
Taking this opportunity, I want to ask how to set different compression methods and other settings here when creating an archive?
from p7zip.
Maybe this will give you the answer.
https://github.com/stonewell/lib7zip
from p7zip.
Related Issues (20)
- Lz4 1.94 available HOT 10
- Can't compile 7z.so, error in _o/bin directory HOT 2
- How to show elapsed / estimated times on command line HOT 1
- How to make 7z in AIX6.1 with gcc9.3? HOT 1
- Is the old branch (17.04) completely removed? HOT 2
- Unable to make file on Ubuntu 22.04 LTS HOT 2
- [Question] How to compress with lz4 ? HOT 7
- [Question] is that feature already exist? HOT 2
- [Feature Request] Preserve permissions
- Proprietary confusion for p7zip-project HOT 1
- [Need Help]patchelf on macos. HOT 2
- Zstandard 1.5.5 out HOT 1
- Could this project be merged into 7-Zip ZS ?
- arm64 NEON HOT 2
- Wrong version on latest release. HOT 1
- Retagging of version 17.05 HOT 1
- Mac OS : Binary of 7-zip is not available HOT 1
- p7zip-17.05 Gentoo Linux compile fails with clang 16.0.1 libcxx HOT 2
- 7zip not recognised by version 17.05 : "Encrypt file names" is SET HOT 2
- Is p7zip affected by remote code execution security vulnerabilities of "normal" 7zip? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from p7zip.