Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/gmtget.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ EXTERN_MSC void gmt_free_list (struct GMT_CTRL *GMT, char **list, uint64_t n);

EXTERN_MSC int GMT_gmtget (void *V_API, int mode, void *args) {
int error = GMT_NOERROR;
char *datasets = NULL, *c = NULL, file[PATH_MAX] = {""};
bool missing = false;
char *datasets = NULL, *c = NULL, file[PATH_MAX] = {""}, path[PATH_MAX] = {""};

struct GMTGET_CTRL *Ctrl = NULL;
struct GMT_CTRL *GMT = NULL, *GMT_cpy = NULL;
Expand Down Expand Up @@ -287,6 +288,7 @@ EXTERN_MSC int GMT_gmtget (void *V_API, int mode, void *args) {
else {
sprintf (file, "@%s", API->remote_info[k].file);
gmt_download_file_if_not_found (GMT, file, GMT_AUTO_DIR);
if (gmt_getdatapath (GMT, &file[1], path, R_OK) == NULL) missing = true;
}
}
}
Expand Down Expand Up @@ -315,10 +317,11 @@ EXTERN_MSC int GMT_gmtget (void *V_API, int mode, void *args) {
while (fscanf (fp, "%s %*s %*s", line) == 1) {
sprintf (file, "@%s", line);
gmt_download_file_if_not_found (GMT, file, GMT_AUTO_DIR);
if (gmt_getdatapath (GMT, &file[1], path, R_OK) == NULL) missing = true;
}
fclose (fp);
}
Return (GMT_NOERROR);
Return (missing ? GMT_FILE_NOT_FOUND : GMT_NOERROR);
}

/* Read the supplied default file or the users defaults to override system settings */
Expand Down
6 changes: 4 additions & 2 deletions src/gmtwhich.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ GMT_LOCAL int gmtwhich_list_tiles (struct GMTAPI_CTRL *API, char *list, unsigned
#define Return(code) {Free_Ctrl (GMT, Ctrl); gmt_end_module (GMT, GMT_cpy); bailout (code);}

EXTERN_MSC int GMT_gmtwhich (void *V_API, int mode, void *args) {
bool list;
bool list, missing = false;
int error = 0, fmode, k_data;
unsigned int first = 0; /* Real start of filename */

Expand Down Expand Up @@ -294,6 +294,7 @@ EXTERN_MSC int GMT_gmtwhich (void *V_API, int mode, void *args) {
GMT_Put_Record (API, GMT_WRITE_DATA, Out);
}
GMT_Report (API, GMT_MSG_ERROR, "File %s not found!\n", &file[first]);
if (Ctrl->G.active) missing = true; /* Asked to fetch it and still don't have it */
}
}

Expand All @@ -302,5 +303,6 @@ EXTERN_MSC int GMT_gmtwhich (void *V_API, int mode, void *args) {
Return (API->error);
}

Return (GMT_NOERROR);
/* -C's purpose is to report Y/N as text without erroring, so it always keeps exiting 0 */
Return ((missing && !Ctrl->C.active) ? GMT_FILE_NOT_FOUND : GMT_NOERROR);
}
Loading