Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

Client7z: auto format/guid detection using 7z.dll

Help
c1tru55
2013-07-14
2013-07-15
  • c1tru55
    c1tru55
    2013-07-14

    Hello to all.

    I use Client7z example with dynamic dll linking. Is there any possibility to automatically detect proper archive format or GUID for opening file? As I see now, I need to set abviously GUID for file in CreateObject function:
    createObjectFunc(&uid, &IID_IInArchive, (void **)&archive)
    Is it possible to open any supported archive format using dll?

    Thanks in advance.

     
  • Igor Pavlov
    Igor Pavlov
    2013-07-14

    7z.dll doesn't contain such code.
    7-Zip uses complex code (OpenArchive.cpp) to open any type archive.
    You can try to use that OpenArchive.h interface.

     
  • c1tru55
    c1tru55
    2013-07-14

    Thanks for the answer Igor!

    I apologize for probably a stupid question, but is it possible to use OpenArchive source code together with 7z.dll?

    and one more question: does it make sense to use the technique of determining proper GUID by file extension? This option is suitable for me, but maybe there are some pitfalls.

    EDITED:
    find answer on my second question by myself: it's cannot be done for iso archive format at least.

     
    Last edit: c1tru55 2013-07-14
  • Igor Pavlov
    Igor Pavlov
    2013-07-14

    1) Yes, for example, 7z.exe uses 7z.dll via OpenArchive.

    2) guid by ext is OK for 80-90% cases.
    And some examples for another cases:
    ISO / UDF with iso etension,
    SFX archives (exe extension),
    renamed archives (like RAR archive with ZIP extension).

     
  • c1tru55
    c1tru55
    2013-07-14

    Trying to use code from Client7z and 7z922\CPP\7zip\UI\Console with OpenArchive, but so far without success.
    g_NumArcs variable in HRESULT CCodecs::Load() function equals to zero and program stops at if (codecs->Formats.Size() == 0) check. It's hard to understand completely how it works, especially if you trying to use it on Qt and C++ is not your primary language...
    My goal is to simply - get list of contents of any supported archive, that's it.
    I think about solution with iteration through each guid and try to open file using it, because it seems most simple way. The only question is: does this not strongly affect the performance?

    Thanks,

     
  • Igor Pavlov
    Igor Pavlov
    2013-07-14

    1) Look
    CPP\7zip\UI\Console\makefile

    2) You need to define
    EXTERNAL_CODECS

    3) Look
    CPP\7zip\UI\Console\Main.cpp
    CCodecs *codecs = new CCodecs;
    CMyComPtr<
    #ifdef EXTERNAL_CODECS
    ICompressCodecsInfo
    #else
    IUnknown
    #endif
    > compressCodecsInfo = codecs;
    HRESULT result = codecs->Load();

     
  • c1tru55
    c1tru55
    2013-07-15

    Thank you very much for help, Igor! All works now like a charm.

    Thanks again for a great library!