MCPcopy Create free account
hub / github.com/RsyncProject/rsync / check_alt_basis_dirs

Function check_alt_basis_dirs

main.c:859–890  ·  view source on GitHub ↗

This function checks on our alternate-basis directories. If we're in * dry-run mode and the destination dir does not yet exist, we'll try to * tweak any dest-relative paths to make them work for a dry-run (the * destination dir must be in curr_dir[] when this function is called). * We also warn about any arg that is non-existent or not a directory. */

Source from the content-addressed store, hash-verified

857 * destination dir must be in curr_dir[] when this function is called).
858 * We also warn about any arg that is non-existent or not a directory. */
859static void check_alt_basis_dirs(void)
860{
861 STRUCT_STAT st;
862 char *slash = strrchr(curr_dir, '/');
863 int j;
864
865 for (j = 0; j < basis_dir_cnt; j++) {
866 char *bdir = basis_dir[j];
867 int bd_len = strlen(bdir);
868 if (bd_len > 1 && bdir[bd_len-1] == '/')
869 bdir[--bd_len] = '\0';
870 if (dry_run > 1 && *bdir != '/') {
871 int len = curr_dir_len + 1 + bd_len + 1;
872 char *new = new_array(char, len);
873 if (slash && strncmp(bdir, "../", 3) == 0) {
874 /* We want to remove only one leading "../" prefix for
875 * the directory we couldn't create in dry-run mode:
876 * this ensures that any other ".." references get
877 * evaluated the same as they would for a live copy. */
878 *slash = '\0';
879 pathjoin(new, len, curr_dir, bdir + 3);
880 *slash = '/';
881 } else
882 pathjoin(new, len, curr_dir, bdir);
883 basis_dir[j] = bdir = new;
884 }
885 if (do_stat(bdir, &st) < 0)
886 rprintf(FWARNING, "%s arg does not exist: %s\n", alt_dest_opt(0), bdir);
887 else if (!S_ISDIR(st.st_mode))
888 rprintf(FWARNING, "%s arg is not a dir: %s\n", alt_dest_opt(0), bdir);
889 }
890}
891
892/* This is only called by the sender. */
893static void read_final_goodbye(int f_in, int f_out)

Callers 2

do_server_recvFunction · 0.85
client_runFunction · 0.85

Calls 4

pathjoinFunction · 0.85
do_statFunction · 0.85
alt_dest_optFunction · 0.85
rprintfFunction · 0.70

Tested by

no test coverage detected