Important alert: (current site time 7/15/2013 5:59:23 PM EDT)
 

VB icon

^! write your own copy command to copy files

Email
Submitted on: 2/5/2004 7:36:25 AM
By: my name is Nitin Jindal (from Panchkula,Haryana)  
Level: Intermediate
User Rating: By 9 Users
Compatibility: C, C++ (general)
Views: 20976
(About the author)
 
     just like DOS Copy command
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
//**************************************
// Name: ^! write your own copy command to copy files
// Description:just like DOS Copy command
// By: my nameis Nitin Jindal (from Panchkula,Haryana)
//
//This code is copyrighted and has// limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=7577&lngWId=3//for details.//**************************************

/******** Now you can write your own copy command to copy.exe or .com or any large file................. Please Vote for me.....Nitin Jindal............*/
#include <stdio.h>
#include <io.h>
#include <fcntl.h>
#include <sys\stat.h>
void fcopy(char *,char *);
main()
{
fcopy("fcopy.exe","fcopy2.exe");
/* fcopy("a:\\fcopy.exe","C:\\test.exe");
 this will copy fcopy.exe file from floppy disk to harddisk */
return 0;
}
void fcopy(char *sname,char *tname)
{
void *buffer;
int bytes,inhandle,outhandle;
inhandle=open(sname,O_RDONLY|O_BINARY);
outhandle=open(tname,O_CREAT|O_BINARY|O_WRONLY|S_IWRITE);
while(1)
{
bytes=read(inhandle,buffer,512);
if(bytes>0)
write(outhandle,buffer,bytes);
else
break;
}
close(inhandle);
close(outhandle);
}


Other 5 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments

7/19/2004 2:03:30 AMmelvyn

What compiler did you used to compile this code?
(If this comment was disrespectful, please report it.)

 
9/27/2004 7:50:28 AMLrd.Sandman

Now you can write your own copy command to copy.exe or .com or any large file


???? You're still using internal commands, so whats the use of it?
(If this comment was disrespectful, please report it.)

 
2/5/2006 6:18:01 AMsatheesh

nice
(If this comment was disrespectful, please report it.)

 
7/30/2008 7:06:41 AMPrashant

Which compiler you are using to compile the code???
(If this comment was disrespectful, please report it.)

 
12/19/2008 10:34:57 AMNensi

What's the use of this Code. You're usin the "copy" command of the DOS. so if you wanna use that you dont have to make it so long. Just #include use namespace std and than copy C:\\xxx.exe D:\\yy.v
This would do exactly what your code does....
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.