Results 1 to 4 of 4
Guys,
I'm investigating how to copy a file located in my file system into another device. I googled to find a solution for my case but I didn't find anything. ...
- 06-01-2010 #1
How to interact with the file system by own C source-code
Guys,
I'm investigating how to copy a file located in my file system into another device. I googled to find a solution for my case but I didn't find anything. My original problem was to find a way to permit my code to move a file into a USB device.
I wonder If is there a way to implement the cp command or some mechanism that permits my code to interact with between the file system on my computer and the second one on USB external driver (FAT32) ???
- 06-01-2010 #2
Execute "bin/cp" with the "system" command.
Debian GNU/Linux -- You know you want it.
- 06-02-2010 #3Linux User
- Join Date
- Jan 2006
- Posts
- 414
Alternatively:
1. open source file in read mode
2. open destination file in write mode
3. copy data over
4. close files
- 06-16-2010 #4Just Joined!
- Join Date
- Jun 2010
- Posts
- 10
systemcall
As USB flash drives mount as files on the local filesystem, (in my distro, in /media/) you can treat them as a local file (everything is a file in unix).
The system will treat this as a no brainer local file copy. you could call system("cp /media/myusbdrive/myfile.foo ~/myfilecopy.foo");
for example at its most basic, you use this within a c program like so:
Code:#include <stdlib.h> int main(void) { system("cp /media/myusbdrive/myfile.foo ~/myfilecopy.foo"); return 0; }Last edited by kingluke; 06-16-2010 at 09:32 PM. Reason: clarity


Reply With Quote