Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

See if using ; under Windows work better for dirs #1124

Merged
merged 6 commits into from
Jul 8, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
No more backslashes
No longer use backslash in movie for dir separator.  Replace any incoming backslash in paths with forward slash.
  • Loading branch information
PaulWessel committed Jul 8, 2019
commit ff92f49355d5b8bb4e6c49962bee5ddc9765e215
1 change: 1 addition & 0 deletions src/gmt_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -2830,6 +2830,7 @@ GMT_LOCAL int gmtinit_set_env (struct GMT_CTRL *GMT) {
gmt_dos_path_fix (GMT->session.DATADIR);
}
#endif
gmt_replace_backslash_in_path (GMT->session.DATADIR);
gmt_strrepc (GMT->session.DATADIR, PATH_SEPARATOR, ','); /* Use comma for OS-independent separator */
}

Expand Down
6 changes: 6 additions & 0 deletions src/gmt_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -8564,6 +8564,12 @@ int gmt_rename_file (struct GMT_CTRL *GMT, const char *oldfile, const char *newf
return errno;
}

void gmt_replace_backslash_in_path (char *dir) {
size_t k = 0;
while (dir[k])
if (dir[k] == '\\') dir[k] = '/';
}

/*! . */
void gmt_set_column (struct GMT_CTRL *GMT, unsigned int direction, unsigned int col, enum gmt_col_enum type) {
/* Sets the column type for this input or output column or both (dir == GMT_IO) */
Expand Down
1 change: 1 addition & 0 deletions src/gmt_prototypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ EXTERN_MSC int gmt_set_psfilename (struct GMT_CTRL *GMT);

/* gmt_io.c: */

EXTERN_MSC void gmt_replace_backslash_in_path (char *dir);
EXTERN_MSC void gmt_disable_bhi_opts (struct GMT_CTRL *GMT);
EXTERN_MSC void gmt_reenable_bhi_opts (struct GMT_CTRL *GMT);
EXTERN_MSC void gmt_insert_tableheader (struct GMT_CTRL *GMT, struct GMT_DATATABLE *T, char *txt);
Expand Down
40 changes: 3 additions & 37 deletions src/movie.c
Original file line number Diff line number Diff line change
Expand Up @@ -858,18 +858,6 @@ void close_files (struct MOVIE_CTRL *Ctrl) {
if (Ctrl->I.active) fclose (Ctrl->I.fp);
}

void double_backslahes_if_dos (char *dir) {
char tmp[PATH_MAX] = {""};
size_t k = 0, j = 0;
if (strchr (dir, '\\') == NULL) return; /* No backslashes */
while (dir[k]) {
if (dir[k] == '\\') tmp[j++] = '\\';
tmp[j++] = dir[k++];
}
tmp[j] = '\0';
strncpy (dir, tmp, j);
}

#define bailout(code) {gmt_M_free_options (mode); return (code);}
#define Return(code) {Free_Ctrl (GMT, Ctrl); gmt_end_module (GMT, GMT_cpy); bailout (code);}

Expand All @@ -891,11 +879,7 @@ int GMT_movie (void *V_API, int mode, void *args) {
char pre_file[PATH_MAX] = {""}, post_file[PATH_MAX] = {""}, main_file[PATH_MAX] = {""}, line[PATH_MAX] = {""}, version[GMT_LEN32] = {""};
char string[GMT_LEN128] = {""}, extra[GMT_LEN256] = {""}, cmd[GMT_LEN256] = {""}, cleanup_file[PATH_MAX] = {""}, L_txt[GMT_LEN128] = {""};
char png_file[PATH_MAX] = {""}, topdir[PATH_MAX] = {""}, datadir[PATH_MAX] = {""}, frame_products[GMT_LEN32] = {MOVIE_RASTER_FORMAT};
#ifdef _WIN32
char dir_sep = '\\';
#else
char dir_sep = '/';
#endif
double percent = 0.0, L_col = 0;

FILE *fp = NULL;
Expand Down Expand Up @@ -1068,7 +1052,7 @@ int GMT_movie (void *V_API, int mode, void *args) {
sprintf (work_dir, ",%s", Ctrl->W.dir);
strcat (datadir, work_dir);
}
double_backslahes_if_dos (datadir); /* Since we will be fprintf the path we must use // for a slash */
gmt_replace_backslash_in_path (datadir); /* Since we will be fprintf the path we must use // for a slash */

/* Create the initialization file with settings common to all frames */

Expand Down Expand Up @@ -1420,20 +1404,10 @@ int GMT_movie (void *V_API, int mode, void *args) {
sprintf (extra, "A+g%s+n", Ctrl->G.fill);
else
sprintf (extra, "A+n"); /* No cropping, image size is fixed */
if (!access ("movie_background.ps", R_OK)) { /* Need to place a background layer first (which is in parent dir when loop script is run) */
#ifdef WIN32
strcat (extra, ",Mb..\\movie_background.ps");
#else
if (!access ("movie_background.ps", R_OK)) /* Need to place a background layer first (which is in parent dir when loop script is run) */
strcat (extra, ",Mb../movie_background.ps");
#endif
}
if (!access ("movie_foreground.ps", R_OK)) { /* Need to append foreground layer at end (which is in parent dir when script is run) */
#ifdef WIN32
strcat (extra, ",Mf..\\movie_foreground.ps");
#else
if (!access ("movie_foreground.ps", R_OK)) /* Need to append foreground layer at end (which is in parent dir when script is run) */
strcat (extra, ",Mf../movie_foreground.ps");
#endif
}
if (Ctrl->H.active) { /* Must pass the DownScaleFactor option to psconvert */
sprintf (line, ",H%d", Ctrl->H.factor);
strncat (extra, line, GMT_LEN128);
Expand Down Expand Up @@ -1533,19 +1507,11 @@ int GMT_movie (void *V_API, int mode, void *args) {
else
sprintf (extra, "A+n"); /* No cropping, image size is fixed */
if (!access ("movie_background.ps", R_OK)) { /* Need to place a background layer first (which will be in parent dir when loop script is run) */
#ifdef WIN32
strcat (extra, ",Mb..\\movie_background.ps");
#else
strcat (extra, ",Mb../movie_background.ps");
#endif
layers = true;
}
if (!access ("movie_foreground.ps", R_OK)) { /* Need to append foreground layer at end (which will be in parent dir when script is run) */
#ifdef WIN32
strcat (extra, ",Mf..\\movie_foreground.ps");
#else
strcat (extra, ",Mf../movie_foreground.ps");
#endif
layers = true;
}
if (Ctrl->H.active) { /* Must pass the DownScaleFactor option to psconvert */
Expand Down