Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tsoc
openmm
Commits
d63d3fc6
Commit
d63d3fc6
authored
Apr 24, 2009
by
Peter Eastman
Browse files
Implemented Platform::loadPluginsFromDirectory()
parent
4c0c5649
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
0 deletions
+51
-0
olla/include/openmm/Platform.h
olla/include/openmm/Platform.h
+10
-0
olla/src/Platform.cpp
olla/src/Platform.cpp
+41
-0
No files found.
olla/include/openmm/Platform.h
View file @
d63d3fc6
...
@@ -181,6 +181,16 @@ public:
...
@@ -181,6 +181,16 @@ public:
* or relative to a set of standard locations.
* or relative to a set of standard locations.
*/
*/
static
void
loadPluginLibrary
(
std
::
string
file
);
static
void
loadPluginLibrary
(
std
::
string
file
);
/**
* Load multiple dynamic libraries (DLLs) which contain OpenMM plugins from a single directory.
* This method loops over every file contained in the specified directory and calls loadPluginLibrary()
* for each one. If an error occurs while trying to load a particular file, that file is simply
* ignored.
*
* @param directory the path to the directory containing libraries to load
* @return the names of all files which were successfully loaded as libraries
*/
static
std
::
vector
<
std
::
string
>
loadPluginsFromDirectory
(
std
::
string
directory
);
private:
private:
// Retarded visual studio compiler complains about being unable to
// Retarded visual studio compiler complains about being unable to
...
...
olla/src/Platform.cpp
View file @
d63d3fc6
...
@@ -40,6 +40,7 @@
...
@@ -40,6 +40,7 @@
#include <sstream>
#include <sstream>
#else
#else
#include <dlfcn.h>
#include <dlfcn.h>
#include <dirent.h>
#endif
#endif
#include <set>
#include <set>
...
@@ -151,3 +152,43 @@ void Platform::loadPluginLibrary(string file) {
...
@@ -151,3 +152,43 @@ void Platform::loadPluginLibrary(string file) {
throw
OpenMMException
(
"Error loading library "
+
file
+
": "
+
dlerror
());
throw
OpenMMException
(
"Error loading library "
+
file
+
": "
+
dlerror
());
#endif
#endif
}
}
vector
<
string
>
Platform
::
loadPluginsFromDirectory
(
string
directory
)
{
vector
<
string
>
files
;
char
dirSeparator
;
#ifdef _MSC_VER
dirSeparator
=
'\\'
;
WIN32_FIND_DATA
fileInfo
;
string
filePattern
(
directory
+
dirSeparator
+
"*"
);
HANDLE
findHandle
=
FindFirstFile
(
filePattern
.
c_str
(),
&
fileInfo
);
if
(
findHandle
!=
INVALID_HANDLE_VALUE
)
{
do
{
if
(
fileInfo
.
cFileName
[
0
]
!=
'.'
)
files
.
push_back
(
string
(
fileInfo
.
cFileName
));
}
while
(
FindNextFile
(
findHandle
,
&
fileInfo
));
FindClose
(
findHandle
);
}
#else
dirSeparator
=
'/'
;
DIR
*
dir
;
struct
dirent
*
entry
;
dir
=
opendir
(
directory
.
c_str
());
if
(
dir
!=
NULL
)
{
while
((
entry
=
readdir
(
dir
))
!=
NULL
)
{
if
(
entry
->
d_name
[
0
]
!=
'.'
)
files
.
push_back
(
string
(
entry
->
d_name
));
}
closedir
(
dir
);
}
#endif
vector
<
string
>
loadedLibraries
;
for
(
unsigned
int
i
=
0
;
i
<
files
.
size
();
++
i
)
{
try
{
Platform
::
loadPluginLibrary
(
directory
+
dirSeparator
+
files
[
i
]);
loadedLibraries
.
push_back
(
files
[
i
]);
}
catch
(
OpenMMException
ex
)
{
// Just ignore it.
}
}
return
loadedLibraries
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment