libite
|
#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <stdio.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/types.h>
#include "lite.h"
Functions | |
int | rsync (char *src, char *dst, int opt, int(*filter)(const char *file)) |
Synchronize contents and optionally remove non-existing backups. More... | |
int rsync | ( | char * | src, |
char * | dst, | ||
int | opt, | ||
int(*)(const char *file) | filter | ||
) |
Synchronize contents and optionally remove non-existing backups.
src | Source directory |
dst | Destination directory |
opt | An option mask of LITE_FOPT_RSYNC_DELETE, LITE_FOPT_KEEP_MTIME |
filter | Optional filtering function for source directory. |
This is a miniature implementation of the famous rsync for local use only. In fact, it is not even a true rsync since it copies all files from src
to dst
. The LITE_FOPT_RSYNC_DELETE opt
flag is useful for creating backups, when set all files removed from src since last backup are pruned from the destination (backup) directory.
The opt
parameter to rsync() is an option mask for the most common rsync(1) options. Previously this argument was called delete
and to maintain backwards compatibility the value 1 is reserved:
LITE_FOPT_RSYNC_DELETE: Prune files from dst
that no longer exist in src
. LITE_FOPT_KEEP_MTIME: Preserve modification time
The filter callback, filter
, if provided, is used to determine what files to include from the source directory when backing up. If a file is to be skipped the callback should simply return zero.
Returns: POSIX OK(0), or non-zero with errno set on error.