.TH LC_SYNCFILELOCAL 3 2023-08-22 "LIBRECAST" "Librecast Programmer's Manual"
.SH NAME
lc_syncfilelocal \- synchronize two local files
.SH LIBRARY
Librecast library
.RI ( liblibrecast ", " \-llibrecast )
.SH SYNOPSIS
.nf
.B #include <librecast/sync.h>
.PP
.BI "int lc_syncfilelocal(const char " *dst ", const char " *src ", q_t " *q "
.BI "        lc_stat_t " *stats ", lc_sync_options_t " *opt ", int " flags ");"
.fi
.PP
Compile and link with \fI\-llibrecast\fP.
.SH DESCRIPTION
The
.BR lc_syncfilelocal ()
function synchronizes the file at
.IR dst
with the file at
.IR src
by overwriting
.IR dst
with bytes from
.IR src .
If
.IR dst
does not exist, it is created.
.PP
If
.IR q
is not NULL, it must point to a queue
.IR q_t
structure previously initialized with
.BR q_init (3).
This queue will have jobs enqueued to build the tree. This is normally used in
conjunction with a threadpool created with
.BR q_pool_create (3)
with threads all calling
.BR q_job_seek (3).
.PP
If
.IR q
is NULL, the creation and destruction of a queue and threadpool will be handled automatically.
.PP
If
.IR stats
is not NULL, transfer statistics will be returned in this structure.
.PP
.IR opt
is not used, at present, and must be NULL for compatibility with future versions.
.PP
The
.IR flags
argument is the bitwise OR of zero of more of the following flags:
.TP
.BR MDEX_RECURSE
recursively index directories.
.PP
.SH RETURN VALUE
The
.BR lc_syncfilelocal ()
function returns zero on success, or -1 if an error occurred.
In the event of an error,
.I errno
is set to indicate the error.
.SH ERRORS
.TP
.BR EINVAL
Invalid argument.
.PP
.BR ENOMEM
Not enough space/cannot allocate memory (POSIX.1-2001).
.PP
.BR lc_syncfilelocal ()
can also fail with any of the errors for
.BR mmap (2)
or
.BR chmod (2).
.PP
.SH SEE ALSO
.BR lc_memsync (3),
.BR lc_sync (3),
.BR lc_syncfile (3),
.BR q_init (3),
.BR q_free (3),
.BR q_pool_create (3),
.BR q_pool_destroy (3),
.BR q_job_seek (3),
.BR chmod (2),
.BR mmap (2)