Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to copy a single file to a different partition in Linux, using C

rename (), link() don't work

Thanks!

like image 552
JJ Liu Avatar asked Dec 07 '25 05:12

JJ Liu


1 Answers

Have you tried using standard old C functions?

`fopen` the source on one partition
`fopen` the destination on the other partition

LOOP while `fread` > 0
   `fread` from the source to a buff
   `fwrite` to the dest from a buff

And then close your files (ie. fclose).

This is also more portable.

EDIT: If you wanted it to be really basic why not just use a scripting language (python/bash) and get it done in a few lines.

like image 156
AusCBloke Avatar answered Dec 08 '25 21:12

AusCBloke



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!