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

Close

#1185 Extracting a archive files One by One Using The CPP SDK

open
nobody
None
5
2014-08-26
2014-03-03
Majid
No

i want extract archive files one by one without whole files. im try \CPP\7zip\UI\Client7z but it extract whole archive.

How can i extract files one, next two, next three and... with Client7z or other samples ???
Is there any way to do it ???
Please help me with sample code in Client7z or another.

Thanks.

Discussion

  • Igor Pavlov
    Igor Pavlov
    2014-03-03

    IInArchive::Extract(const UInt32* indices, UInt32 numItems, Int32 testMode, IArchiveExtractCallback *extractCallback)
    

    You can specify indexes of files that you want to extract in sorted order.

     
    Last edit: Igor Pavlov 2014-03-03
  • Majid
    Majid
    2014-03-03

    1.I try this code in Client7z but all files extracted in all cases for example when i enter 0 - 1 - 2 instead of Null or second parameter of Extract function all files extracted no one selected file extracting.

    // Extract command
    CArchiveExtractCallback *extractCallbackSpec = new CArchiveExtractCallback;
    CMyComPtr<IArchiveExtractCallback> extractCallback(extractCallbackSpec);
    extractCallbackSpec->Init(archive, L""); // second parameter is output folder path
    extractCallbackSpec->PasswordIsDefined = false;
    // extractCallbackSpec->PasswordIsDefined = true;
    // extractCallbackSpec->Password = L"1";
    HRESULT result = archive->Extract(NULL, (UInt32)(Int32)(-1), false, extractCallback);

    2.In Client7z sample in bellow code How can i extract specified file when in for loop read all file size and paths after this two operation???

      // List command
      UInt32 numItems = 0;
      archive->GetNumberOfItems(&numItems);
      for (UInt32 i = 0; i < numItems; i++)
      {
        {
          // Get uncompressed size of file
          NCOM::CPropVariant prop;
          archive->GetProperty(i, kpidSize, &prop);
          UString s = ConvertPropVariantToString(prop);
          PrintString(s);
          PrintString("  ");
        }
        {
          // Get name of file
          NCOM::CPropVariant prop;
          archive->GetProperty(i, kpidPath, &prop);
          UString s = ConvertPropVariantToString(prop);
          PrintString(s);
        }
        PrintNewLine();
      }
    

    Please help me with source code for extract one specified file. for example in Client7z sample because it is simple to use of 7z sdk. i realy need this feature for extract files.
    Thanks a lot.

     
    Last edit: Majid 2014-03-03
  • Majid
    Majid
    2014-03-04

    Done!

    Thanks Sir...

     
  • Majid
    Majid
    2014-03-04

    Hello

    in this code of Client7z How can i detect that one archive is protected with password or not ???

    // Extract command
    CArchiveExtractCallback *extractCallbackSpec = new CArchiveExtractCallback;
    CMyComPtr<IArchiveExtractCallback> extractCallback(extractCallbackSpec);
    extractCallbackSpec->Init(archive, L""); // second parameter is output folder path
    extractCallbackSpec->PasswordIsDefined = false;
    // extractCallbackSpec->PasswordIsDefined = true;
    // extractCallbackSpec->Password = L"1";

    Thanks...

     
  • Igor Pavlov
    Igor Pavlov
    2014-03-04

    IInArchive::GetArchiveProperty
    kpidMethod
    can show that there is encrypted file.
    Or you can check kpidMethod for any file in archive.
    If header is enctypted then 7z.dll will request
    ICryptoGetTextPassword.

     
    • Majid
      Majid
      2014-03-05

      Thanks
      i do it but that show compressing and encryption method and that is different in another archives.

      i have two problems in Extracting archives:

      1. How can i get archive password protected status as a boolean value (true/false) for protected or not???

      2. How can i extract "all archive root files and all files of it in all sub folders" in one directory no extract in original form of archive with all directories??? I need extract all files of archive in one directory, i don't want extract archive files with directories.

      Really Thanks.