mirror of
https://github.com/edubart/otclient.git
synced 2025-11-30 23:26:51 +01:00
Remove boost::filesystem dependency
This commit is contained in:
@@ -184,7 +184,7 @@ message(STATUS "Build revision: ${BUILD_REVISION}")
|
||||
add_definitions(-D"BUILD_REVISION=\\\"${BUILD_REVISION}\\\"")
|
||||
|
||||
# find boost
|
||||
set(REQUIRED_BOOST_COMPONENTS system filesystem thread chrono)
|
||||
set(REQUIRED_BOOST_COMPONENTS system thread chrono)
|
||||
if(WIN32)
|
||||
set(Boost_THREADAPI win32)
|
||||
set(framework_DEFINITIONS ${framework_DEFINITIONS} -DBOOST_THREAD_USE_LIB) # fix boost thread linkage
|
||||
|
||||
@@ -31,9 +31,6 @@
|
||||
#include <framework/platform/crashhandler.h>
|
||||
#include <framework/platform/platform.h>
|
||||
|
||||
#include <boost/locale.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/filesystem/fstream.hpp>
|
||||
#include <locale>
|
||||
|
||||
#ifdef FW_NET
|
||||
@@ -75,8 +72,6 @@ void Application::init(std::vector<std::string>& args)
|
||||
|
||||
// setup locale
|
||||
std::locale::global(std::locale());
|
||||
std::locale utf8("en_US.UTF-8");
|
||||
boost::filesystem::path::imbue(utf8);
|
||||
|
||||
// process args encoding
|
||||
g_platform.processArgs(args);
|
||||
|
||||
@@ -25,9 +25,9 @@
|
||||
|
||||
#include <framework/core/application.h>
|
||||
#include <framework/luaengine/luainterface.h>
|
||||
#include <framework/platform/platform.h>
|
||||
|
||||
#include <physfs.h>
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
ResourceManager g_resources;
|
||||
|
||||
@@ -298,7 +298,7 @@ std::string ResourceManager::getRealDir(const std::string& path)
|
||||
|
||||
std::string ResourceManager::getCurrentDir()
|
||||
{
|
||||
return boost::filesystem::current_path().generic_string<std::string>() + "/";
|
||||
return g_platform.getCurrentDir();
|
||||
}
|
||||
|
||||
std::string ResourceManager::getBaseDir()
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user