extracting files from a rar/zip

This is a discussion on extracting files from a rar/zip within the Windows Programming forums, part of the Platform Specific Boards category; how do i extract all of the files from a rar/zip file? I'm not sure, but i think i can ...

  1. #1
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    University of Waterloo
    Posts
    1,903

    extracting files from a rar/zip

    how do i extract all of the files from a rar/zip file? I'm not sure, but i think i can use the System(....) command to do this.....

    i looked at the WinRar readme, but it didn't help much......

    so, what i need to be able to do is i have a path name that i want to extract to, and i have the zip/rar, but i just can't get the zip/rar to unextract itself to the folder that the user specified (this is for my installer i'm making)

    thanks in advance

  2. #2
    Dev
    Dev is offline
    Registered User Dev's Avatar
    Join Date
    Mar 2003
    Posts
    59
    Look out for 7-Zip.

    It's an open source software and allows your programs to call its command line version for doing zip unzip / rar unrar.

    It works with some 6-7 compressed formats.

  3. #3
    Dev
    Dev is offline
    Registered User Dev's Avatar
    Join Date
    Mar 2003
    Posts
    59
    www.7-zip.org

    Taken from Help file

    Command Line Syntax
    7z <command> [<switch>...] <base_archive_name> [<arguments>...]

    <arguments> ::= <switch> | <wildcard> | <filename> | <list_file>
    <switch>::= <switch_symbol><switch_characters>[<option>]
    <switch_symbol> ::= '/' | '-'
    <list_file> ::= @{filename}

    Expressions in square brackets (between '[' and ']') are optional.

    Expressions in curly braces ('{' and '}') means that instead that Expression (including braces) must be used some string.

    Expression

    expression1 | expression2 | ... | expressionN

    means that any (but only one) from these expressions must be specified.

    Commands and switches can be entered in upper or lower case.

    Command is the first non-switch argument.

    The "base_archive_name" must be the first filename on the command line after the command.

    The switches and other filenames can be in any order.

    Wildcards or filenames with spaces must be quoted:

    "Dir\Program files\*"
    Dir\"Program files"\*

    Switch options can be combined to save command line length. However, some switch options take optional string arguments and therefore, must be the last option in a combined argument token string because 7-Zip accepts the rest of the argument token as the optional argument.

    7-Zip uses wild name matching similar to Windows 95:

    '*' means a sequence of arbitrary characters.
    '?' means any character.
    Examples:

    *.txt means all files with an extension of ".txt"
    ?a* means all files with a second character of "a"
    *1* means all names that contains character "1"
    *.*.* means all names that contain two "." means characters

    The default wildcard "*" will be used if there is no filename/wildcard in command line.

    Restrictions for wildcards and filenames for archiving files:

    Wildcards and filenames can't contain disk name or network name. Every wildcard/filename path is treated as path from current directory on disk and as path from root directory in archive. In other words, the first part of path (letters before first slash ('\') symbol) always must be name or wildcard.
    Wildcards and filenames can't be ended by slash ('\') symbol.
    Wildcards can contain wildcard characters ('*' and '?') only in last part of path.
    Examples:

    Dir1\*.cpp OK
    c:\Dir1\*.cpp ILLEGAL: path contains disk name
    Dir1\Dir2\g?.txt OK
    Dir1\D?r2\file1.txt ILLEGAL: there is a wildcard char in non last part

    These restrictions do not act to filenames and directory names used not as archiving files.

    List file
    You can supply one or more filenames or wildcards for special list files (files containing lists of files). The filenames in such list file must be separated by space, tab or new line symbol(s). Wildcards or filenames with spaces must be quoted.

    Multiple list files are supported.

    For example, if contents of file "listfile.txt" is the following:

    "My programs\*.cpp"
    Src\*.cpp

    then command

    7z a -tzip archive.zip @listfile.txt

    adds to archive "archive.zip" all "*.cpp" files from directories "My programs" and "Src".

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. add source files to embedded VC 4.0
    By George2 in forum C++ Programming
    Replies: 4
    Last Post: 06-13-2006, 03:28 AM
  2. *.cpp and *.h files understanding
    By ElastoManiac in forum C++ Programming
    Replies: 4
    Last Post: 06-11-2006, 04:45 AM
  3. Linking header files, Source files and main program(Accel. C++)
    By Daniel Primed in forum C++ Programming
    Replies: 3
    Last Post: 01-17-2006, 10:46 AM
  4. Multiple Cpp Files
    By w4ck0z in forum C++ Programming
    Replies: 5
    Last Post: 11-14-2005, 01:41 PM
  5. header and source files
    By gtriarhos in forum C Programming
    Replies: 3
    Last Post: 10-02-2005, 03:16 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21