LC_SYNCFILELOCAL(3)

πŸ’– LC_SYNCFILELOCAL β€” the Librecast Programmer's Manual, but make it slay πŸ’–

okay bestie, sit down, hydrate, and let's talk about lc_syncfilelocal from the Librecast library. this is lc_syncfilelocal(3) and she is literally the file-copying bestie you never knew you needed 🫢


🌸 NAME 🌸

lc_syncfilelocal β€” synchronize two local files. yes queen, that's the whole job. two files, one destiny πŸ’…


πŸ“š LIBRARY πŸ“š

Librecast library (liblibrecast, -llibrecast). that's the vibe, that's the link flag, that's the whole library situation ✨


πŸŽ€ SYNOPSIS πŸŽ€

#include <librecast/sync.h>

int lc_syncfilelocal(const char *dst, const char *src, q_t *q
        lc_stat_t *stats, lc_sync_options_t *opt, int flags);

Compile and link with -llibrecast.

⚠️ bestie look closely at that signature β€” there's no comma between q_t *q and lc_stat_t *stats in the synopsis. that's how it's written in the manual, so that's how it stays. copy-paste responsibly, iykyk πŸ’€

✨ DESCRIPTION ✨

so here's the tea. lc_syncfilelocal() takes the file at dst and synchronizes it with the file at src β€” by overwriting dst with bytes from src. and if dst doesn't exist yet? no worries, she just creates it. main character energy fr fr 🌈

now, the q argument. if q is not NULL, it has to point to a queue q_t structure that was previously initialized with q_init(3). this queue is gonna have jobs enqueued onto it to build the tree 🌳. this is normally used in conjunction with a threadpool created with q_pool_create(3), where the threads are all calling q_job_seek(3). teamwork makes the dream work, no cap πŸ’œ

if q is NULL, then the creation and destruction of a queue and threadpool gets handled automatically for you. she's independent, she doesn't need you, she's got it πŸ’…

if stats is not NULL, transfer statistics will be returned in this structure πŸ“Š.

opt is not used at present, and it must be NULL for compatibility with future versions. so like, don't get creative with it, bestie πŸ™ˆ

the flags argument is the bitwise OR of zero or more of the following flags:

πŸ¦‹ OPTIONS πŸ¦‹

  • MDEX_RECURSE β€” recursively index directories. that's it, that's the whole flag list, she's a one-flag wonder and honestly? iconic πŸ‘‘

πŸ”₯ RETURN VALUE πŸ”₯

lc_syncfilelocal() returns zero on success, or -1 if an error occurred. and if there's an error, errno gets set to indicate what went wrong. so always check your return value, bestie, don't just assume it ate 😭


πŸ’€ ERRORS πŸ’€

  • EINVAL β€” Invalid argument.
  • ENOMEM β€” Not enough space/cannot allocate memory (POSIX.1-2001).

and listen: lc_syncfilelocal() can also fail with any of the errors for mmap(2) or chmod(2). so if you get a weird one, check those pages too, she's got range 🫢


πŸ‘‘ SEE ALSO πŸ‘‘

lc_memsync(3), lc_sync(3), lc_syncfile(3), q_init(3), q_free(3), q_pool_create(3), q_pool_destroy(3), q_job_seek(3), chmod(2), mmap(2)


and that's the whole page, bestie!! πŸ’–

this little icon was brought to you by LIBRECAST, dated 2023-08-22, and filed under LC_SYNCFILELOCAL(3). go sync some files, you absolute legend πŸŽ€βœ¨πŸ¦‹

πŸ“¦ where this page comes from