self extracting zip files

A

Andrew Edwards

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
 
E

Emmanuel Delahaye

Andrew Edwards said:
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.
 
M

Mr. 4X

Andrew Edwards said:
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 :)
 
A

ak

|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
 
A

Andrew Edwards

Emmanuel Delahaye said:
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
 
M

Malcolm

Andrew Edwards said:
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().
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top