Revision: 76104
          http://sourceforge.net/p/brlcad/code/76104
Author:   starseeker
Date:     2020-06-10 19:24:32 +0000 (Wed, 10 Jun 2020)
Log Message:
-----------
read-input-file is like the batch mode processing mode of the main command

Modified Paths:
--------------
    brlcad/branches/bioh/src/burst2/burst.cpp

Modified: brlcad/branches/bioh/src/burst2/burst.cpp
===================================================================
--- brlcad/branches/bioh/src/burst2/burst.cpp   2020-06-10 19:12:38 UTC (rev 
76103)
+++ brlcad/branches/bioh/src/burst2/burst.cpp   2020-06-10 19:24:32 UTC (rev 
76104)
@@ -54,6 +54,9 @@
 
 #define DEFAULT_BURST_PROMPT "burst> "
 
+/* Forward declare so we can use this function in a command
+ * called by this function */
+int burst_process_line(struct burst_state *s, const char *line);
 
 #define PURPOSEFLAG "--print-purpose"
 #define HELPFLAG "--print-help"
@@ -222,8 +225,6 @@
        ret = BRLCAD_ERROR;
     }
 
-    // TODO logCMd
-
     bu_vls_free(&msg);
     return ret;
 }
@@ -1053,15 +1054,24 @@
 
     if (!s || !argc || !argv) return BRLCAD_ERROR;
 
-    FILE *cmdfp = fopen(argv[1], "rb");
-    if (!cmdfp) {
-       printf("failed to open command file: %s\n", argv[1]);
+    std::ifstream fs;
+    fs.open(argv[1]);
+    if (!fs.is_open()) {
+       bu_log("Unable to open command file: %s\n", argv[1]);
        return BRLCAD_ERROR;
     }
+    std::string bline;
+    while (std::getline(fs, bline)) {
+       if (burst_process_line(s, bline.c_str()) != BRLCAD_OK) {
+           bu_log("Error processing line: %s\n", bline.c_str());
+           fs.close();
+           return BRLCAD_ERROR;
+       }
+       /* build up a command history buffer for write-input-file */
+       bu_vls_printf(&s->cmdhist, "%s\n", bline.c_str());
+    }
+    fs.close();
 
-    // TODO - use bu_cmd to process the lines in the file
-
-    fclose(cmdfp);
     return ret;
 }
 

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