|
-
Oct 13th, 2001, 08:08 PM
#1
Thread Starter
Member
Even easier than cout << "Hello, World!"
How do you copy a file to another directory, say, "script.iss" in the current directory to "c:\temp"?
-
Oct 13th, 2001, 08:38 PM
#2
Monday Morning Lunatic
Code:
system("copy script.iss c:\\temp");
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Oct 13th, 2001, 08:39 PM
#3
Thread Starter
Member
Somehow I'm thinking that isn't the cleanest way.
-
Oct 13th, 2001, 08:41 PM
#4
Monday Morning Lunatic
Well, there's there's always the API...
CopyFile
The CopyFile function copies an existing file to a new file.
The CopyFileEx function provides two additional capabilities. CopyFileEx can call a specified callback function each time a portion of the copy operation is completed, and CopyFileEx can be canceled during the copy operation.
BOOL CopyFile(
LPCTSTR lpExistingFileName, // name of an existing file
LPCTSTR lpNewFileName, // name of new file
BOOL bFailIfExists // operation if file exists
);
Parameters
lpExistingFileName
[in] Pointer to a null-terminated string that specifies the name of an existing file.
Windows NT/2000 or later: In the ANSI version of this function, the name is limited to MAX_PATH characters. To extend this limit to nearly 32,000 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. For more information, see File Name Conventions.
Windows 95/98/Me: This string must not exceed MAX_PATH characters.
lpNewFileName
[in] Pointer to a null-terminated string that specifies the name of the new file.
Windows NT/2000 or later: In the ANSI version of this function, the name is limited to MAX_PATH characters. To extend this limit to nearly 32,000 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. For more information, see File Name Conventions.
Windows 95/98/Me: This string must not exceed MAX_PATH characters.
bFailIfExists
[in] Specifies how this operation is to proceed if a file of the same name as that specified by lpNewFileName already exists. If this parameter is TRUE and the new file already exists, the function fails. If this parameter is FALSE and the new file already exists, the function overwrites the existing file and succeeds
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Oct 13th, 2001, 08:41 PM
#5
Thread Starter
Member
I saw that but I don't know what constants to pass and check for. Got an example?
-
Oct 13th, 2001, 08:44 PM
#6
Monday Morning Lunatic
Uh...
Code:
CopyFile("script.iss", "c:\\temp\\script.iss", FALSE);
...is what I'd assume
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Oct 13th, 2001, 09:16 PM
#7
Thread Starter
Member
But it returns something; what constants (ERROR_SUCCESS, etc) can I use to check the return value?
-
Oct 13th, 2001, 09:17 PM
#8
PowerPoster
Originally posted by parksie
Code:
system("copy script.iss c:\\temp");
what is wrong with system?
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
-
Oct 13th, 2001, 09:17 PM
#9
Thread Starter
Member
Doesn't that fork out a process?
-
Oct 13th, 2001, 09:28 PM
#10
PowerPoster
yeah, i think, but..
is this for the installer thing?
for something small it should be fine.
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
-
Oct 13th, 2001, 09:46 PM
#11
Thread Starter
Member
Yes, it is. Let's see what this does...
-
Oct 13th, 2001, 10:18 PM
#12
Fanatic Member
Originally posted by filburt1
But it returns something; what constants (ERROR_SUCCESS, etc) can I use to check the return value?
ERROR_SUCCESS == oxymoron
Alcohol & calculus don't mix.
Never drink & derive.
-
Oct 14th, 2001, 10:26 AM
#13
Thread Starter
Member
Originally posted by parksie
Code:
system("copy script.iss c:\\temp");
How would I know if that executed correctly; does system return the return value of the process?
-
Oct 14th, 2001, 11:13 AM
#14
Monday Morning Lunatic
Don't know. However, if it fails, then "File not found" or something (whatever is printed by copy) will be outputted to stdout or stderr (can't remember which, never tested ).
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Oct 14th, 2001, 11:13 AM
#15
Thread Starter
Member
Probably stderr.
-
Oct 15th, 2001, 05:18 AM
#16
Addicted Member
I know system("cls") and the copy-thing you were talking about, but are there some else system-commands?
-
Oct 15th, 2001, 07:07 AM
#17
Monday Morning Lunatic
system just passes them to the underlying system, in this case DOS (or for NT-based, cmd.exe).
So you could do system("echo %PATH%");
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Oct 15th, 2001, 07:11 AM
#18
Addicted Member
ok, cool.......
can you pass programs to start? like.....system("program.exe")?
-
Oct 15th, 2001, 11:21 AM
#19
Monday Morning Lunatic
Anything that can be interpreted by the command line interpreter
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Oct 15th, 2001, 12:07 PM
#20
Addicted Member
kewl, will try it.........
-
Oct 15th, 2001, 03:12 PM
#21
system() is cool. =). Just my 2 cents.
Z.
-
Oct 16th, 2001, 07:57 AM
#22
also, there is ShellExecute()
this is API
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Oct 17th, 2001, 10:30 AM
#23
Addicted Member
I like system("command")
didn't thought it was such a command........
try it!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|