Remove boost::filesystem dependency

This commit is contained in:
Eduardo Bart
2013-02-22 19:29:58 -03:00
parent 09c937998f
commit 04c4943fa8
7 changed files with 26 additions and 9 deletions

View File

@@ -35,6 +35,7 @@ public:
bool isProcessRunning(const std::string& name);
bool killProcess(const std::string& name);
std::string getTempPath();
std::string getCurrentDir();
bool copyFile(std::string from, std::string to);
bool fileExists(const std::string& file);
void openUrl(std::string url);

View File

@@ -79,6 +79,15 @@ std::string Platform::getTempPath()
return "/tmp/";
}
std::string Platform::getCurrentDir()
{
std::string res;
char cwd[2048];
if(getcwd(cwd, sizeof(cwd)) != NULL)
res = cwd;
return res;
}
bool Platform::copyFile(std::string from, std::string to)
{
return system(stdext::format("/bin/cp '%s' '%s'", from, to).c_str()) == 0;

View File

@@ -88,6 +88,16 @@ std::string Platform::getTempPath()
return stdext::utf16_to_utf8(path);
}
std::string Platform::getCurrentDir()
{
std::string ret;
wchar_t path[MAX_PATH];
GetCurrentDirectoryW(MAX_PATH, path);
ret = stdext::utf16_to_utf8(path);
boost::replace_all(ret, "\\", "/");
return ret;
}
bool Platform::fileExists(const std::string& file)
{
std::wstring wfile = stdext::utf8_to_utf16(file);