Skip to content

Commit c574f0c

Browse files
Fix module loading to not copy file. (#8)
* Fix module loading to not copy file. * Update patch version.
1 parent 8f894ce commit c574f0c

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cmake_minimum_required(VERSION 3.10)
22

3-
project(flow-core VERSION 1.1.0 LANGUAGES CXX)
3+
project(flow-core VERSION 1.1.1 LANGUAGES CXX)
44

55
set(CMAKE_CXX_STANDARD 20)
66
set(CMAKE_CXX_STANDARD_REQUIRED ON)

src/Env.cpp

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,16 @@ void Env::LoadModule(const std::filesystem::path& file)
3939
_loaded_modules.erase(file.filename().string());
4040
}
4141

42-
const auto new_module_file = std::filesystem::current_path() / "modules" / file.filename();
43-
if (new_module_file != file)
44-
{
45-
std::filesystem::copy_file(file, new_module_file, std::filesystem::copy_options::overwrite_existing);
46-
}
47-
4842
#ifdef FLOW_WINDOWS
49-
HINSTANCE handle = LoadLibrary(new_module_file.string().c_str());
43+
HINSTANCE handle = LoadLibrary(file.string().c_str());
5044
if (!handle)
5145
{
52-
throw std::runtime_error("Error loading file: " + new_module_file.string());
46+
throw std::runtime_error("Error loading file: " + file.string());
5347
}
5448

5549
auto register_func = GetProcAddress(handle, NodeFactory::RegisterModuleFuncName);
5650
#else
57-
void* handle = dlopen(new_module_file.c_str(), RTLD_LAZY);
51+
void* handle = dlopen(file.c_str(), RTLD_LAZY);
5852
if (!handle)
5953
{
6054
throw std::runtime_error("Error loading file: " + std::string(dlerror()));
@@ -66,7 +60,7 @@ void Env::LoadModule(const std::filesystem::path& file)
6660
if (auto RegisterModule_func = std::bit_cast<NodeFactory::ModuleMethod_t>(register_func))
6761
{
6862
RegisterModule_func(_factory);
69-
_loaded_modules.emplace(new_module_file.filename().string(), std::bit_cast<void*>(handle));
63+
_loaded_modules.emplace(file.filename().string(), std::bit_cast<void*>(handle));
7064
return;
7165
}
7266

@@ -75,7 +69,7 @@ void Env::LoadModule(const std::filesystem::path& file)
7569
#else
7670
dlclose(handle);
7771
#endif
78-
throw std::runtime_error("Error loading symbol for RegisterModule from " + new_module_file.filename().string());
72+
throw std::runtime_error("Error loading symbol for RegisterModule from " + file.filename().string());
7973
}
8074

8175
void Env::LoadModules(const std::filesystem::path& extension_path)

0 commit comments

Comments
 (0)