Remove boost::filesystem dependency
This commit is contained in:
parent
09c937998f
commit
04c4943fa8
|
@ -26,7 +26,6 @@
|
|||
|
||||
#include <framework/xml/tinyxml.h>
|
||||
#include <framework/core/resourcemanager.h>
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
CreatureManager g_creatures;
|
||||
|
||||
|
@ -196,6 +195,8 @@ void CreatureManager::loadNpcs(const std::string& folder)
|
|||
if(!stdext::ends_with(tmp, "/"))
|
||||
tmp += "/";
|
||||
|
||||
// FIXME: filesystem is not supported anymore, rework the following code with g_resources
|
||||
/*
|
||||
boost::filesystem::path npcPath(boost::filesystem::current_path().generic_string() + tmp);
|
||||
if(!boost::filesystem::exists(npcPath))
|
||||
stdext::throw_exception(stdext::format("NPCs folder '%s' was not found.", folder));
|
||||
|
@ -207,6 +208,7 @@ void CreatureManager::loadNpcs(const std::string& folder)
|
|||
|
||||
loadCreatureBuffer(g_resources.readFileContents(tmp + f));
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void CreatureManager::loadSpawns(const std::string& fileName)
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue