WebFramework v3.0.12
Web framework for C++.
Loading...
Searching...
No Matches
DynamicLibraries.cpp
1#include "DynamicLibraries.h"
2
3#include <format>
4
5#include "Exceptions/FileDoesNotExistException.h"
6
7#ifdef __LINUX__
8#include <dlfcn.h>
9#endif
10
11using namespace std;
12
13namespace framework
14{
15 namespace utility
16 {
17 string makePathToDynamicLibrary(const filesystem::path& pathToSource)
18 {
19 if (pathToSource.has_extension())
20 {
21 return pathToSource.string();
22 }
23
24#ifdef __LINUX__
25 filesystem::path temp(pathToSource);
26 filesystem::path parent = temp.parent_path();
27 filesystem::path fileName = temp.filename();
28
29 return format("{}/lib{}.so", parent.string(), fileName.string());
30#else
31 return format("{}.dll", pathToSource.string());
32#endif
33 }
34 }
35}