Stellarator-Tools
copy_file.c File Reference

Functions to fast copy files. More...

#include <sys/errno.h>
#include <fcntl.h>
#include <sys/sendfile.h>
#include <sys/stat.h>
#include <unistd.h>

Macros

#define COPYFILE_ALL   0
 Flag to copy the enture file.
 

Functions

size_t copyfile (const char *src, const char *dest, const int unused_1, const int unused_2)
 Copy a file from the source to the destination. More...
 
int copy_file_c (const char *src, const char *dest)
 Copy a file from the source to the destination. More...
 

Detailed Description

Functions to fast copy files.

MPI and calls to fork do not mix well. In place of slow copies this makes Kernel function calls to the OS fast copy systems by passing a fork to the cp command.

Function Documentation

◆ copy_file_c()

int copy_file_c ( const char *  src,
const char *  dest 
)

Copy a file from the source to the destination.

Copy file returns the error status. Check errno to see the error that occurred.

Parameters
[in]srcPath to the source file to copy.
[in]destPath to the destination file to copy.
Returns
Error code.

◆ copyfile()

size_t copyfile ( const char *  src,
const char *  dest,
const int  unused_1,
const int  unused_2 
)

Copy a file from the source to the destination.

Linux does not define the copyfile function. Define one using the sendfile(2) function.

Parameters
[in]srcPath to the source file to copy.
[in]destPath to the destination file to copy.
[in]unused_1Unused argument.
[in]unused_2Unused argument.
Returns
Error status.