Using system calls with C program

Accessing a copy/paste system call in Windows OS through C program

Page 1 of 1

1 Replies - 2761 Views - Last Post: 27 May 2009 - 07:54 AM Rate Topic: -----

#1 matrixaffiliate  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 17-April 09

Using system calls with C program

Post icon  Posted 27 May 2009 - 06:28 AM

I'm writing a program for work that needs to copy a file from a directory on one drive to another, e.g. from a flash drive to the hard drive. Originally I had planned on simply opening the file and using fread to read through the file and then using fwrite to "recreate" the file on the new drive. That code worked fine, but it doesn't do well for large files. A friend suggested using a system call to copy and paste the file from one drive to the other, but everything I'm finding on it refers to UNIX environments and there are several different examples. Since this program will only ever be used on Windows machines can I still use this system call idea and if I can, would you mind giving me some example code of where to start. From the White Bible to Google I've seen enough code that I've managed to confuse myself royally.

This is the code I have right now.

FILE *in;
FILE *out
						
fopen=in("E:\\folderA\\%s"fileA, "rb")	   //fileA is a *char[]
fopen=out("C:\\folderB\\fileB", "wb+")
						
/*System Call to copy paste
This is where I originally had my fread command
and my fwrite command. */
						
fclose(in);
fclose(out);



Thank you for your help!
Matrixaffiliate

This post has been edited by matrixaffiliate: 27 May 2009 - 06:30 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Using system calls with C program

#2 matrixaffiliate  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 17-April 09

Re: Using system calls with C program

Posted 27 May 2009 - 07:54 AM

I think I found an option that seems to be working. I'm using CopyFile() which is a Windows API function I found surfing through the help on VS 2008. It was a little confusing at first but I think It works now. When I'm positive it's effective I'll post the code for anyone else that has a similar question.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1