/** * Parse the source and destination paths that the user has provided. */ void DCOPY_parse_path_args(char** argv, \ int optind_local, \ int argc) { /* compute number of paths and index of last argument */ int num_args = argc - optind_local; int last_arg_index = num_args + optind_local - 1; /* we need to have at least two paths, * one or more sources and one destination */ if(argv == NULL || num_args < 2) { if(DCOPY_global_rank == 0) { DCOPY_print_usage(); MFU_LOG(MFU_LOG_ERR, "You must specify a source and destination path"); } MPI_Barrier(MPI_COMM_WORLD); DCOPY_exit(EXIT_FAILURE); } /* determine number of source paths */ src_params = NULL; num_src_params = last_arg_index - optind_local; /* allocate space to record info about each source */ size_t src_params_bytes = ((size_t) num_src_params) * sizeof(mfu_param_path); src_params = (mfu_param_path*) MFU_MALLOC(src_params_bytes); /* record standardized paths and stat info for each source */ int opt_index; for(opt_index = optind_local; opt_index < last_arg_index; opt_index++) { char* path = argv[opt_index]; int idx = opt_index - optind_local; mfu_param_path_set(path, &src_params[idx]); } /* standardize destination path */ const char* dstpath = argv[last_arg_index]; mfu_param_path_set(dstpath, &dest_param); /* copy the destination path to user opts structure */ DCOPY_user_opts.dest_path = MFU_STRDUP(dest_param.path); /* check that source and destinations are ok */ DCOPY_check_paths(); }
/* look up mtimes for specified file, * return secs/nsecs in newly allocated mfu_pred_times struct, * return NULL on error */ static mfu_pred_times* get_mtimes(const char* file) { mfu_param_path param_path; mfu_param_path_set(file, ¶m_path); if (! param_path.path_stat_valid) { return NULL; } mfu_pred_times* t = (mfu_pred_times*) MFU_MALLOC(sizeof(mfu_pred_times)); mfu_stat_get_mtimes(¶m_path.path_stat, &t->secs, &t->nsecs); mfu_param_path_free(¶m_path); return t; }