Extracting Files Using 7z.dll

2014-01-26
2014-01-26
  • DominicanJB
    DominicanJB
    2014-01-26

    I want to develop a program to archive (compress) and retrieve (extract) all the files in a specified folder. So far I have been able to successfully replicate the example shown in "Client7z.cpp" which uses the library 7z.dll.

    My questions so far are:

    1) How do one extract files with or without path? In other words, where in the code can one program the choice of whether or not extract an archive with or without path?

    2) Which of the property ID's (kpid) represents the compressed size of each file in the archive? Based on the code in "Client7z.cpp," kpidSize represents the uncompressed size; which kpid represents the compressed size?

    Thanks,

    DominicanJB

     
  • Igor Pavlov
    Igor Pavlov
    2014-01-26

    1) look code that uses kpidPath
    2) Look PropID.h
    kpidPackSize

     
    • DominicanJB
      DominicanJB
      2014-01-26

      1) The extracting callback class has a function called extractCallbackSpec->GetStream
      with the following arguments:
      A) UInt32 index = the index of the ith file in the archive
      B) ISequentialOutStream **outStream = What is this?
      C) Int32 askExtractMode = What is this?

      Let's say I want to extract the ith file without path, then I'd use kpidShortName instead of kpidPath in the line of code RINOK(_archiveHandler->GetProperty(index, kpidPath, &prop));? If so, what would I set outStream & askExtractMode to?

      Thanks again,
      DominicanJB

       
      • Igor Pavlov
        Igor Pavlov
        2014-01-26

        b) pointer to stream for writing data
        c) look NAskMode in IArchive.h
        You can't set askExtractMode. 7z.dll sends askExtractMode value to your code.

        You don't need kpidShortName. kpidShortName is old DOS 8.3 name for ntfs archives.

        Use kpidPath. And then remove directory prefix from result string.

         
        Last edit: Igor Pavlov 2014-01-26
  • DominicanJB
    DominicanJB
    2014-01-26

    So one way of doing it (not necessarily the best) is to:
    1) Create a global bool variable, say StripPath = true (when extracting without path); false = (extracting including path).

    2) In the function CArchiveExtractCallback::GetStream(. . . .)
    instead of _filePath = fullPath;
    change to _filePath = (StripPath == true) ? RemoveDir(fullPath) : fullpath;

    where the function RemoveDir(fullPath) removes the directory from the full path.

    Thanks again for your support,

    DominicanJB