Implement Copy, move and delete a file in Linux- rename, unlink

Hi Guys,

In this post, we will see how to use Linux API's to perform copy, move and delete file operations

There is no direct Linux System Call for copy operation, we need to manually open one file in read mode, and other in create mode, and then start writing one by one

For move operation, the Linux System call is rename

 #include <stdio.h>

 int rename(const char *oldpath, const char *newpath);

For delete operation, the Linux System call is unlink

#include <unistd.h>

int unlink(const char *pathname);


Sample Code to use all the API's




Output:


Comments

Popular posts from this blog

bb.utils.contains yocto

make config vs oldconfig vs defconfig vs menuconfig vs savedefconfig

PR, PN and PV Variable in Yocto