Modified FilePluginProvider to use FSNodes (instead of raw filenames / paths) in its API

svn-id: r34709
This commit is contained in:
Max Horn 2008-09-30 16:34:38 +00:00
parent 1d7de023d9
commit 73b833042e
10 changed files with 34 additions and 25 deletions

View file

@ -27,6 +27,7 @@
#include "backends/plugins/dc/dc-provider.h"
#include "backends/plugins/dynamic-plugin.h"
#include "common/fs.h"
#include "dcloader.h"
@ -83,12 +84,13 @@ public:
};
Plugin* DCPluginProvider::createPlugin(const Common::String &filename) const {
return new DCPlugin(filename);
Plugin* DCPluginProvider::createPlugin(const Common::FilesystemNode &node) const {
return new DCPlugin(node.getPath());
}
bool DCPluginProvider::isPluginFilename(const Common::String &filename) const {
bool DCPluginProvider::isPluginFilename(const Common::FilesystemNode &node) const {
// Check the plugin suffix
Common::String filename = node.getName();
if (!filename.hasSuffix(".PLG"))
return false;

View file

@ -32,9 +32,9 @@
class DCPluginProvider : public FilePluginProvider {
protected:
Plugin* createPlugin(const Common::String &filename) const;
Plugin* createPlugin(const Common::FilesystemNode &node) const;
bool isPluginFilename(const Common::String &filename) const;
bool isPluginFilename(const Common::FilesystemNode &node) const;
virtual void addCustomDirectories(Common::StringList &dirs) const {
dirs.push_back("/");

View file

@ -27,6 +27,7 @@
#include "backends/plugins/posix/posix-provider.h"
#include "backends/plugins/dynamic-plugin.h"
#include "common/fs.h"
#include <dlfcn.h>
@ -78,8 +79,8 @@ public:
};
Plugin* POSIXPluginProvider::createPlugin(const Common::String &filename) const {
return new POSIXPlugin(filename);
Plugin* POSIXPluginProvider::createPlugin(const Common::FilesystemNode &node) const {
return new POSIXPlugin(node.getPath());
}

View file

@ -32,7 +32,7 @@
class POSIXPluginProvider : public FilePluginProvider {
protected:
Plugin* createPlugin(const Common::String &filename) const;
Plugin* createPlugin(const Common::FilesystemNode &node) const;
};
#endif // defined(DYNAMIC_MODULES) && defined(UNIX)

View file

@ -27,6 +27,7 @@
#include "backends/plugins/sdl/sdl-provider.h"
#include "backends/plugins/dynamic-plugin.h"
#include "common/fs.h"
#include "SDL.h"
#include "SDL_loadso.h"
@ -78,8 +79,8 @@ public:
};
Plugin* SDLPluginProvider::createPlugin(const Common::String &filename) const {
return new SDLPlugin(filename);
Plugin* SDLPluginProvider::createPlugin(const Common::FilesystemNode &node) const {
return new SDLPlugin(node.getPath());
}

View file

@ -32,7 +32,7 @@
class SDLPluginProvider : public FilePluginProvider {
protected:
Plugin* createPlugin(const Common::String &filename) const;
Plugin* createPlugin(const Common::FilesystemNode &node) const;
};
#endif // defined(DYNAMIC_MODULES) && defined(UNIX)

View file

@ -27,6 +27,7 @@
#include "backends/plugins/win32/win32-provider.h"
#include "backends/plugins/dynamic-plugin.h"
#include "common/fs.h"
#include <windows.h>
@ -96,12 +97,13 @@ public:
};
Plugin* Win32PluginProvider::createPlugin(const Common::String &filename) const {
return new Win32Plugin(filename);
Plugin* Win32PluginProvider::createPlugin(const Common::FilesystemNode &node) const {
return new Win32Plugin(node.getPath());
}
bool Win32PluginProvider::isPluginFilename(const Common::String &filename) const {
bool Win32PluginProvider::isPluginFilename(const Common::FilesystemNode &node) const {
// Check the plugin suffix
Common::String filename = node.getName();
if (!filename.hasSuffix(".dll"))
return false;

View file

@ -32,9 +32,9 @@
class Win32PluginProvider : public FilePluginProvider {
protected:
Plugin* createPlugin(const Common::String &filename) const;
Plugin* createPlugin(const Common::FilesystemNode &node) const;
bool isPluginFilename(const Common::String &filename) const;
bool isPluginFilename(const Common::FilesystemNode &node) const;
virtual void addCustomDirectories(Common::StringList &dirs) const {}
};

View file

@ -231,8 +231,8 @@ PluginList FilePluginProvider::getPlugins() {
}
for (Common::FSList::const_iterator i = files.begin(); i != files.end(); ++i) {
if (isPluginFilename(i->getName())) {
pl.push_back(createPlugin(i->getPath()));
if (isPluginFilename(*i)) {
pl.push_back(createPlugin(*i));
}
}
}
@ -240,7 +240,9 @@ PluginList FilePluginProvider::getPlugins() {
return pl;
}
bool FilePluginProvider::isPluginFilename(const Common::String &filename) const {
bool FilePluginProvider::isPluginFilename(const Common::FilesystemNode &node) const {
Common::String filename = node.getName();
#ifdef PLUGIN_PREFIX
// Check the plugin prefix
if (!filename.hasPrefix(PLUGIN_PREFIX))

View file

@ -32,6 +32,7 @@
namespace Common {
class FSList;
class FilesystemNode;
}
@ -238,19 +239,19 @@ protected:
* Subclasses of FilePluginProvider have to at least overload this method.
* If the file is not found, or does not contain loadable code, 0 is returned instead.
*
* @param filename the name of the loadable code module
* @param node the FSNode of the loadable code module
* @return a pointer to a Plugin instance, or 0 if an error occurred.
*/
virtual Plugin *createPlugin(const Common::String &filename) const = 0;
virtual Plugin *createPlugin(const Common::FilesystemNode &node) const = 0;
/**
* Check if the supplied filename corresponds to a loadable plugin file in
* the current platform.
* Check if the supplied file corresponds to a loadable plugin file in
* the current platform. Usually, this will just check the file name.
*
* @param filename the name of the file to check
* @param node the FSNode of the file to check
* @return true if the filename corresponds to a plugin, false otherwise
*/
virtual bool isPluginFilename(const Common::String &filename) const;
virtual bool isPluginFilename(const Common::FilesystemNode &node) const;
/**
* Optionally add to the list of directories to be searched for