diff --git a/src/debugger/Debugger.cxx b/src/debugger/Debugger.cxx index b4d308cb1..7668676f0 100644 --- a/src/debugger/Debugger.cxx +++ b/src/debugger/Debugger.cxx @@ -211,13 +211,13 @@ string Debugger::autoExec() { ostringstream buf; - // autoexec.stella is always run - FilesystemNode autoexec(myOSystem.baseDir() + "autoexec.stella"); + // autoexec.script is always run + FilesystemNode autoexec(myOSystem.baseDir() + "autoexec.script"); buf << "autoExec():" << endl << myParser->exec(autoexec) << endl; - // Also, "romname.stella" if present - FilesystemNode romname(myOSystem.romFile().getPathWithExt(".stella")); + // Also, "romname.script" if present + FilesystemNode romname(myOSystem.romFile().getPathWithExt(".script")); buf << myParser->exec(romname) << endl; // Init builtins diff --git a/src/debugger/DebuggerParser.cxx b/src/debugger/DebuggerParser.cxx index 7a95211c6..c3234a06b 100644 --- a/src/debugger/DebuggerParser.cxx +++ b/src/debugger/DebuggerParser.cxx @@ -129,7 +129,7 @@ string DebuggerParser::exec(const FilesystemNode& file) { ifstream in(file.getPath()); if(!in.is_open()) - return red("autoexec file \'" + file.getShortPath() + "\' not found"); + return red("script file \'" + file.getShortPath() + "\' not found"); ostringstream buf; int count = 0; @@ -142,13 +142,13 @@ string DebuggerParser::exec(const FilesystemNode& file) run(command); count++; } - buf << "Executed " << count << " commands from \"" + buf << "\nExecuted " << count << " commands from \"" << file.getShortPath() << "\""; return buf.str(); } else - return red("autoexec file \'" + file.getShortPath() + "\' not found"); + return red("script file \'" + file.getShortPath() + "\' not found"); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -572,12 +572,16 @@ string DebuggerParser::trapStatus(const Trap& trap) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool DebuggerParser::saveScriptFile(string file) +string DebuggerParser::saveScriptFile(string file) { - if( file.find_last_of('.') == string::npos ) - file += ".stella"; + // Append 'script' extension when necessary + if(file.find_last_of('.') == string::npos) + file += ".script"; - ofstream out(file); + FilesystemNode node(debugger.myOSystem.defaultSaveDir() + file); + ofstream out(node.getPath()); + if(!out.is_open()) + return "Unable to save script to " + node.getShortPath(); FunctionDefMap funcs = debugger.getFunctionDefMap(); for(const auto& f: funcs) @@ -608,7 +612,7 @@ bool DebuggerParser::saveScriptFile(string file) for(const auto& cond: conds) out << "breakif {" << cond << "}" << endl; - return out.good(); + return "saved " + node.getShortPath() + " OK"; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -959,8 +963,13 @@ void DebuggerParser::executeDump() // "exec" void DebuggerParser::executeExec() { - FilesystemNode file(argStrings[0]); - commandResult << exec(file); + // Append 'script' extension when necessary + string file = argStrings[0]; + if(file.find_last_of('.') == string::npos) + file += ".script"; + + FilesystemNode node(debugger.myOSystem.defaultSaveDir() + file); + commandResult << exec(node); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1429,10 +1438,7 @@ void DebuggerParser::executeS() // "save" void DebuggerParser::executeSave() { - if(saveScriptFile(argStrings[0])) - commandResult << "saved script to file " << argStrings[0]; - else - commandResult << red("I/O error"); + commandResult << saveScriptFile(argStrings[0]); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/debugger/DebuggerParser.hxx b/src/debugger/DebuggerParser.hxx index 363fe2ecc..726d96700 100644 --- a/src/debugger/DebuggerParser.hxx +++ b/src/debugger/DebuggerParser.hxx @@ -65,7 +65,7 @@ class DebuggerParser bool getArgs(const string& command, string& verb); bool validateArgs(int cmd); string eval(); - bool saveScriptFile(string file); + string saveScriptFile(string file); private: enum { kNumCommands = 76 };