Revision: 77113
          http://sourceforge.net/p/brlcad/code/77113
Author:   starseeker
Date:     2020-09-13 00:09:36 +0000 (Sun, 13 Sep 2020)
Log Message:
-----------
See if we can get rtwizard's working dir out of the binary directory if it's 
set there - if that's a read-only location we get some nasty side effects like 
duplicate dirbuild objects in the tree.

Modified Paths:
--------------
    brlcad/branches/RELEASE/src/rtwizard/main.c

Modified: brlcad/branches/RELEASE/src/rtwizard/main.c
===================================================================
--- brlcad/branches/RELEASE/src/rtwizard/main.c 2020-09-12 19:08:22 UTC (rev 
77112)
+++ brlcad/branches/RELEASE/src/rtwizard/main.c 2020-09-13 00:09:36 UTC (rev 
77113)
@@ -24,6 +24,10 @@
 #include "common.h"
 #include "string.h"
 
+#ifdef HAVE_WINDOWS_H
+#  include <direct.h> /* For chdir */
+#endif
+
 #include "tcl.h"
 
 #include "vmath.h"
@@ -1010,6 +1014,20 @@
        bu_exit(EXIT_SUCCESS, NULL);
     }
 
+    /* If the working directory is BU_DIR_BIN, try shifting to the user's
+     * home directory instead */
+    char cwd[MAXPATHLEN] = {0};
+    char bindir[MAXPATHLEN] = {0};
+    bu_dir(cwd, MAXPATHLEN, BU_DIR_CURR, NULL);
+    bu_dir(bindir, MAXPATHLEN, BU_DIR_BIN, NULL);
+    if (BU_STR_EQUAL(cwd, bindir)) {
+       bu_dir(cwd, MAXPATHLEN, BU_DIR_HOME, NULL);
+       if (chdir(cwd)) {
+           bu_exit(EXIT_FAILURE, "Working directory is the binary directory 
\"%s\" (read-only), and chdir to home directory \"%s\" failed.  RtWizard 
requires a read/write working directory.", bindir, cwd);
+       }
+    }
+
+
     {
        int stop = 0;
        for (i = 0; i < uac; i++) {

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to