From 1d9c12ce1ccc7ea4c68ca5fd0e4e35fd8bb2b62b Mon Sep 17 00:00:00 2001 From: GokuWeedLord Date: Wed, 13 Dec 2017 23:08:16 +1100 Subject: [PATCH] remove module cache code --- .../Server_Zone/Script/ScriptLoader.cpp | 24 ++++--------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/src/servers/Server_Zone/Script/ScriptLoader.cpp b/src/servers/Server_Zone/Script/ScriptLoader.cpp index 9e08e52a..b6dff3f6 100644 --- a/src/servers/Server_Zone/Script/ScriptLoader.cpp +++ b/src/servers/Server_Zone/Script/ScriptLoader.cpp @@ -55,16 +55,10 @@ Core::Scripting::ScriptInfo* Core::Scripting::ScriptLoader::loadModule( const st return nullptr; } - // copy to temp dir - boost::filesystem::path cacheDir( f.parent_path() /= g_serverZone.getConfig()->getValue< std::string >( "Settings.General.Scripts.CachePath", "./cache/" ) ); - boost::filesystem::create_directories( cacheDir ); - boost::filesystem::path dest( cacheDir /= f.filename().string() ); - boost::filesystem::copy_file( f, dest, boost::filesystem::copy_option::overwrite_if_exists ); - #ifdef _WIN32 - ModuleHandle handle = LoadLibrary( dest.string().c_str() ); + ModuleHandle handle = LoadLibrary( path.c_str() ); #else - ModuleHandle handle = dlopen( dest.string().c_str(), RTLD_LAZY ); + ModuleHandle handle = dlopen( path.c_str(), RTLD_LAZY ); #endif if( !handle ) @@ -79,7 +73,7 @@ Core::Scripting::ScriptInfo* Core::Scripting::ScriptLoader::loadModule( const st auto info = new ScriptInfo; info->handle = handle; info->library_name = f.stem().string(); - info->library_path = dest.string(); + info->library_path = path; m_scriptMap.insert( std::make_pair( f.stem().string(), info ) ); @@ -120,18 +114,10 @@ bool Core::Scripting::ScriptLoader::unloadScript( ModuleHandle handle ) { if( it->second->handle == handle ) { - auto info = it->second; + delete it->second; m_scriptMap.erase( it ); - if( unloadModule( handle ) ) - { - // remove cached file - boost::filesystem::remove( info->library_path ); - - return true; - } - - return false; + return unloadModule( handle ); } }