From 7d62e64bf193c1d18f544c0041c4dd14d923d5da Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Thu, 19 Sep 2019 16:47:03 -0400 Subject: [PATCH] Fix "Save as" function. --- src/Prototype.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Prototype.cpp b/src/Prototype.cpp index 1944015..0d09069 100644 --- a/src/Prototype.cpp +++ b/src/Prototype.cpp @@ -231,20 +231,20 @@ struct Prototype : Module { std::string ext = string::filenameExtension(string::filename(path)); std::string dir = asset::plugin(pluginInstance, "examples"); std::string filename = "Untitled." + ext; - char* pathC = osdialog_file(OSDIALOG_SAVE, dir.c_str(), filename.c_str(), NULL); - if (!pathC) { + char* newPathC = osdialog_file(OSDIALOG_SAVE, dir.c_str(), filename.c_str(), NULL); + if (!newPathC) { return; } - std::string path = pathC; - std::free(pathC); + std::string newPath = newPathC; + std::free(newPathC); // Add extension if user didn't specify one - std::string pathExt = string::filenameExtension(string::filename(path)); - if (pathExt == "") - path += "." + ext; + std::string newExt = string::filenameExtension(string::filename(newPath)); + if (newExt == "") + newPath += "." + ext; - std::ofstream f(path); + std::ofstream f(newPath); f << script; - path = path; + path = newPath; } };