#include<algorithm>
#include<cstdlib>
+#include<creaWx.h>
+#include<wx/config.h>
+
namespace CDMUtilities
{
template <typename Container>
#if(_WIN32)
// ------ Windows
- //TODO: implementation for windows
+ std::vector<std::string> pathSplit;
+
+ splitter::split(pathSplit, path, CDMUtilities::SLASH, splitter::no_empties);
+
+ if(0 < pathSplit.size())
+ pathFixed = pathSplit[0];
+
+ for (int i = 1; i < (int)(pathSplit.size()); i++)
+ {
+ pathFixed += CDMUtilities::SLASH + pathSplit[i];
+ }
#else
// ------ LINUX / MacOS
//break path into folders
- std::vector<std::string> pathSlpit;
+ std::vector<std::string> pathSplit;
- splitter::split(pathSlpit, path, CDMUtilities::SLASH, splitter::no_empties);
+ splitter::split(pathSplit, path, CDMUtilities::SLASH, splitter::no_empties);
- for (int i = 0; i < pathSlpit.size(); i++)
+ for (int i = 0; i < pathSplit.size(); i++)
{
- pathFixed += CDMUtilities::SLASH + pathSlpit[i];
+ pathFixed += CDMUtilities::SLASH + pathSplit[i];
}
#endif
return pathFixed;
int openTextEditor(const std::string& file)
{
- std::string command = TEXT_EDITOR;
+ wxConfigBase* pConfig = wxConfigBase::Get();
+ std::string command = crea::wx2std(pConfig->Read(wxT("TEXT_EDITOR"), crea::std2wx(CDMUtilities::TEXT_EDITOR)));
if(file != "")
- command += " \"" + file + "\" &";
+ command += " \"" + file + "\"";
+ command += " &";
return system(command.c_str());
}
int openFileExplorer(const std::string& file)
{
- std::string command = FILE_EXPLORER;
+ wxConfigBase* pConfig = wxConfigBase::Get();
+ std::string command = crea::wx2std(pConfig->Read(wxT("FILE_EXPLORER"), crea::std2wx(CDMUtilities::FILE_EXPLORER)));
if(file != "")
- command += " \"" + file + "\" &";
+ command += " \"" + file + "\"";
+ command += " &";
return system(command.c_str());
}
{
std::string comm = command;
if(file != "")
- comm += " \"" + file + "\" &";
+ comm += " \"" + file + "\"";
+ comm += " &";
return system(comm.c_str());
}
int openCreaToolsTools()
{
+#ifdef _WIN32
+ std::string comm = "creaTools &";
+#else
std::string comm = "creaTools.sh &";
+#endif
+
return system(comm.c_str());
}
int openTerminal(const std::string& command)
{
- std::string comm = TERMINAL;
+ wxConfigBase* pConfig = wxConfigBase::Get();
+ std::string comm = crea::wx2std(pConfig->Read(wxT("TERMINAl"), crea::std2wx(CDMUtilities::TERMINAL)));
if (command != "")
comm += + " " + command;
comm += " &";
std::vector<std::string> words;
splitter::split(words,name," \\/\",.'`",splitter::no_empties);
std::string fixedName = "";
- for (int i = 0; i < words.size(); i++)
+ for (int i = 0; i < (int)(words.size()); i++)
{
fixedName += words[i];
}
return true;
}
+ std::string stringify(const std::string& line)
+ {
+ std::string res;
+ for (int i = 0; i < (int)(line.size()); i++)
+ {
+ if(line[i] == '\\')
+ res.push_back('\\');
+ if(line[i] == '\"')
+ res.push_back('\\');
+ res.push_back(line[i]);
+ }
+ return res;
+ }
+
}