MCPcopy Index your code
hub / github.com/RsyncProject/rsync / copy_altdest_file

Function copy_altdest_file

generator.c:912–946  ·  view source on GitHub ↗

Copy a file found in our --copy-dest handling. */

Source from the content-addressed store, hash-verified

910
911/* Copy a file found in our --copy-dest handling. */
912static int copy_altdest_file(const char *src, const char *dest, struct file_struct *file)
913{
914 char buf[MAXPATHLEN];
915 const char *copy_to, *partialptr;
916 int save_preserve_xattrs = preserve_xattrs;
917 int ok, fd_w;
918
919 if (inplace) {
920 /* Let copy_file open the destination in place. */
921 fd_w = -1;
922 copy_to = dest;
923 } else {
924 fd_w = open_tmpfile(buf, dest, file);
925 if (fd_w < 0)
926 return -1;
927 copy_to = buf;
928 }
929 cleanup_set(copy_to, NULL, NULL, -1, -1);
930 if (copy_file(src, copy_to, fd_w, file->mode) < 0) {
931 if (INFO_GTE(COPY, 1)) {
932 rsyserr(FINFO, errno, "copy_file %s => %s",
933 full_fname(src), copy_to);
934 }
935 /* Try to clean up. */
936 unlink(copy_to);
937 cleanup_disable();
938 return -1;
939 }
940 partialptr = partial_dir ? partial_dir_fname(dest) : NULL;
941 preserve_xattrs = 0; /* xattrs were copied with file */
942 ok = finish_transfer(dest, copy_to, src, partialptr, file, 1, 0);
943 preserve_xattrs = save_preserve_xattrs;
944 cleanup_disable();
945 return ok ? 0 : -1;
946}
947
948/* This is only called for regular files. We return -2 if we've finished
949 * handling the file, -1 if no dest-linking occurred, or a non-negative

Callers 1

try_dests_regFunction · 0.85

Calls 8

open_tmpfileFunction · 0.85
cleanup_setFunction · 0.85
copy_fileFunction · 0.85
full_fnameFunction · 0.85
cleanup_disableFunction · 0.85
partial_dir_fnameFunction · 0.85
finish_transferFunction · 0.85
rsyserrFunction · 0.70

Tested by

no test coverage detected