470,848 Members | 2,653 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,848 developers. It's quick & easy.

self extracting zip files

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
Nov 13 '05 #1
6 2442
In 'comp.lang.c', "Andrew Edwards" <ed*******@spamfreeusa.com> 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- em**********@noos.fr [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/
Nov 13 '05 #2
"Andrew Edwards" <ed*******@spamfreeusa.com> 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


Nov 13 '05 #3
ak
On Sat, 12 Jul 2003 19:19:13 GMT, "Andrew Edwards" <ed*******@spamfreeusa.com>
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
Nov 13 '05 #4
"Emmanuel Delahaye" <em**********@noos.fr> 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
Nov 13 '05 #5
"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
Nov 13 '05 #6

"Andrew Edwards" <ed*******@spamfreeusa.com> 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().
Nov 13 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Nazgul | last post: by
3 posts views Thread by wenz | last post: by
reply views Thread by k_nil | last post: by
2 posts views Thread by bjm | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.