copy

copy — Utility functions to copy and move files

Synopsis

#include <atomic-install/copy.h>

int                 ai_cp_a                             (const char *source,
                                                         const char *dest);
int                 ai_cp_l                             (const char *source,
                                                         const char *dest);
int                 ai_mv                               (const char *source,
                                                         const char *dest);

Description

libai-copy provides a few convenience functions to copy and move files, preserving their ownership, permissions, mtimes and extended attributes.

Details

ai_cp_a ()

int                 ai_cp_a                             (const char *source,
                                                         const char *dest);

Copy the contents and attributes of source file to dest. Preserve permissions, extended attributes, mtime. Try to copy as fast as possible but always create a new file.

If source is a directory, then a new directory will be created at dest, and permissions and extended attributes will be copied from source. The destination directory must not exist.

source :

current file path

dest :

new complete file path

Returns :

0 on success, errno value on failure.

ai_cp_l ()

int                 ai_cp_l                             (const char *source,
                                                         const char *dest);

Create a copy of file source as dest as atomically as possible. Preserve permissions, extended attributes, mtime. The resulting file may be a hardlink to the source file.

source :

current file path

dest :

new complete file path

Returns :

0 on success, errno value on failure.

ai_mv ()

int                 ai_mv                               (const char *source,
                                                         const char *dest);

Move file from source to dest as atomically as possible. Preserve permissions, extended attributes, mtime.

source :

current file path

dest :

new complete file path

Returns :

0 on success, errno value on failure.