self extracting zip files

Discussion in 'C Programming' started by Andrew Edwards, Jul 12, 2003.

  1. I have program that downloads a file from the internet and extracts it using
    calls to system(). All files are extracted into the directory where my
    program is located. How do I redirect the extracted files to a specified
    directory?

    I can use the following:

    system("move *.* c:\directory");

    However, this will move my program. I end up having to call system for every
    file in the directory since most of them are .exe.

    Your assistance is greatly appreciated.
    Andrew
    Andrew Edwards, Jul 12, 2003
    #1
    1. Advertising

  2. In 'comp.lang.c', "Andrew Edwards" <> wrote:

    > I have program that downloads a file from the internet and extracts it
    > using calls to system(). All files are extracted into the directory
    > where my program is located. How do I redirect the extracted files to a
    > specified directory?
    >
    > I can use the following:
    >
    > system("move *.* c:\directory");
    >
    > However, this will move my program. I end up having to call system for
    > every file in the directory since most of them are .exe.


    By-definition, the contain of the string passed to system() is strongly
    system-dependent. Better to ask on a newsgroup dedicated to your platform.

    --
    -ed- [remove YOURBRA before answering me]
    The C-language FAQ: http://www.eskimo.com/~scs/C-faq/top.html
    <blank line>
    FAQ de f.c.l.c : http://www.isty-info.uvsq.fr/~rumeau/fclc/
    Emmanuel Delahaye, Jul 12, 2003
    #2
    1. Advertising

  3. Andrew Edwards

    Mr. 4X Guest

    "Andrew Edwards" <> wrote:

    > I have program that downloads a file from the internet and extracts it
    > using calls to system(). All files are extracted into the directory
    > where my program is located. How do I redirect the extracted files to
    > a specified directory?
    >
    > I can use the following:
    >
    > system("move *.* c:\directory");


    Well... system(...) is standardized, but the OS commands that you can pass
    to it are system specific.

    BTW if you want to redefine the target directory into which a zip SFX is
    unzipped to then you could try unzipping it with an unzip utility instead
    of running it. Or maybe some kinds of the self extracting ZIPs could have a
    command line switch to redefine the target directory. End of off topic
    stuff :)

    > However, this will move my program. I end up having to call system for
    > every file in the directory since most of them are .exe.
    >
    > Your assistance is greatly appreciated.
    > Andrew
    >
    >
    Mr. 4X, Jul 12, 2003
    #3
  4. Andrew Edwards

    ak Guest

    On Sat, 12 Jul 2003 19:19:13 GMT, "Andrew Edwards" <>
    wrote:

    |I have program that downloads a file from the internet and extracts it using
    |calls to system(). All files are extracted into the directory where my
    |program is located. How do I redirect the extracted files to a specified
    |directory?
    |
    |I can use the following:
    |
    | system("move *.* c:\directory");
    |
    |However, this will move my program. I end up having to call system for every
    |file in the directory since most of them are .exe.
    |
    |Your assistance is greatly appreciated.
    |Andrew
    |

    maybe you could use the lib "Info-Zip" and build in the extract
    function into your program, that would give you more control.

    http://www.info-zip.org/pub/infozip/

    hth
    ak




    --
    g a n d a l f @ p c . n u
    ak, Jul 12, 2003
    #4
  5. "Emmanuel Delahaye" <> wrote:

    > By-definition, the contain of the string passed to system() is strongly
    > system-dependent. Better to ask on a newsgroup dedicated to your platform.
    >


    I would much rather eliminate the use of system(); However, since I'm new to
    programming and did not want to ask you to do the work for me, I decided to
    use the best thing I could find. Maybe you could give me a few pointers on
    how to do this in standard C.

    Thanks,
    Andrew
    Andrew Edwards, Jul 12, 2003
    #5
  6. "ak" <ak @ workmail.com> wrote...

    > maybe you could use the lib "Info-Zip" and build in the extract
    > function into your program, that would give you more control.
    >
    > http://www.info-zip.org/pub/infozip/
    >


    Thanks, I'll look into it immediately.

    Andrew
    Andrew Edwards, Jul 12, 2003
    #6
  7. Andrew Edwards

    Malcolm Guest

    "Andrew Edwards" <> wrote in message
    >
    > I would much rather eliminate the use of system();
    >

    system() is cluntzy. You will hardly ever find it in real code (at least in
    a games programming environment).
    >
    > Maybe you could give me a few pointers on how to do this in standard C.
    >

    C has no directory functions in the standard library. This was probably a
    bad decison, but was presumably done since some platforms don't have
    anything that could be described as a hierarchical filing system.

    It is unusual for a non-trivial C program to rely entirely on the standard
    library. You don't need to worry too much about using a platform-specific
    extension to handle your directory operations. If portability is a concern,
    you can isolate the platform-specific code in its own files. Then you
    provide an interface to the rest of the program.

    eg

    char **listdir(char *path)

    is your function to list all files in a directory (you will have to make a
    decison on sub-directories and special files like UNIX ..).

    Then for each platform you write code to list the directory. Under Windows
    you use repeated calls to FindNextFile() after setting up FindFirstFile().
    Malcolm, Jul 12, 2003
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bomb Diggy
    Replies:
    17
    Views:
    1,184
    Roedy Green
    Aug 29, 2003
  2. Calvin FONG
    Replies:
    12
    Views:
    1,117
    Calvin FONG
    Feb 19, 2004
  3. Ralf W. Grosse-Kunstleve
    Replies:
    16
    Views:
    561
    Lonnie Princehouse
    Jul 11, 2005
  4. Ralf W. Grosse-Kunstleve
    Replies:
    18
    Views:
    582
    Bengt Richter
    Jul 11, 2005
  5. Ralf W. Grosse-Kunstleve
    Replies:
    2
    Views:
    390
    Dan Sommers
    Jul 12, 2005
Loading...

Share This Page