Search code examples
clinuxcopymovedisk-partitioning

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


rename (), link() don't work

Thanks!


Solution

  • 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.