Modified FilePluginProvider to use FSNodes (instead of raw filenames / paths) in its API
svn-id: r34709
This commit is contained in:
parent
1d7de023d9
commit
73b833042e
10 changed files with 34 additions and 25 deletions
|
@ -27,6 +27,7 @@
|
||||||
|
|
||||||
#include "backends/plugins/dc/dc-provider.h"
|
#include "backends/plugins/dc/dc-provider.h"
|
||||||
#include "backends/plugins/dynamic-plugin.h"
|
#include "backends/plugins/dynamic-plugin.h"
|
||||||
|
#include "common/fs.h"
|
||||||
|
|
||||||
#include "dcloader.h"
|
#include "dcloader.h"
|
||||||
|
|
||||||
|
@ -83,12 +84,13 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
Plugin* DCPluginProvider::createPlugin(const Common::String &filename) const {
|
Plugin* DCPluginProvider::createPlugin(const Common::FilesystemNode &node) const {
|
||||||
return new DCPlugin(filename);
|
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
|
// Check the plugin suffix
|
||||||
|
Common::String filename = node.getName();
|
||||||
if (!filename.hasSuffix(".PLG"))
|
if (!filename.hasSuffix(".PLG"))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
|
@ -32,9 +32,9 @@
|
||||||
|
|
||||||
class DCPluginProvider : public FilePluginProvider {
|
class DCPluginProvider : public FilePluginProvider {
|
||||||
protected:
|
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 {
|
virtual void addCustomDirectories(Common::StringList &dirs) const {
|
||||||
dirs.push_back("/");
|
dirs.push_back("/");
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
|
|
||||||
#include "backends/plugins/posix/posix-provider.h"
|
#include "backends/plugins/posix/posix-provider.h"
|
||||||
#include "backends/plugins/dynamic-plugin.h"
|
#include "backends/plugins/dynamic-plugin.h"
|
||||||
|
#include "common/fs.h"
|
||||||
|
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
|
|
||||||
|
@ -78,8 +79,8 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
Plugin* POSIXPluginProvider::createPlugin(const Common::String &filename) const {
|
Plugin* POSIXPluginProvider::createPlugin(const Common::FilesystemNode &node) const {
|
||||||
return new POSIXPlugin(filename);
|
return new POSIXPlugin(node.getPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
|
|
||||||
class POSIXPluginProvider : public FilePluginProvider {
|
class POSIXPluginProvider : public FilePluginProvider {
|
||||||
protected:
|
protected:
|
||||||
Plugin* createPlugin(const Common::String &filename) const;
|
Plugin* createPlugin(const Common::FilesystemNode &node) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // defined(DYNAMIC_MODULES) && defined(UNIX)
|
#endif // defined(DYNAMIC_MODULES) && defined(UNIX)
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
|
|
||||||
#include "backends/plugins/sdl/sdl-provider.h"
|
#include "backends/plugins/sdl/sdl-provider.h"
|
||||||
#include "backends/plugins/dynamic-plugin.h"
|
#include "backends/plugins/dynamic-plugin.h"
|
||||||
|
#include "common/fs.h"
|
||||||
|
|
||||||
#include "SDL.h"
|
#include "SDL.h"
|
||||||
#include "SDL_loadso.h"
|
#include "SDL_loadso.h"
|
||||||
|
@ -78,8 +79,8 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
Plugin* SDLPluginProvider::createPlugin(const Common::String &filename) const {
|
Plugin* SDLPluginProvider::createPlugin(const Common::FilesystemNode &node) const {
|
||||||
return new SDLPlugin(filename);
|
return new SDLPlugin(node.getPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
|
|
||||||
class SDLPluginProvider : public FilePluginProvider {
|
class SDLPluginProvider : public FilePluginProvider {
|
||||||
protected:
|
protected:
|
||||||
Plugin* createPlugin(const Common::String &filename) const;
|
Plugin* createPlugin(const Common::FilesystemNode &node) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // defined(DYNAMIC_MODULES) && defined(UNIX)
|
#endif // defined(DYNAMIC_MODULES) && defined(UNIX)
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
|
|
||||||
#include "backends/plugins/win32/win32-provider.h"
|
#include "backends/plugins/win32/win32-provider.h"
|
||||||
#include "backends/plugins/dynamic-plugin.h"
|
#include "backends/plugins/dynamic-plugin.h"
|
||||||
|
#include "common/fs.h"
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
|
@ -96,12 +97,13 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
Plugin* Win32PluginProvider::createPlugin(const Common::String &filename) const {
|
Plugin* Win32PluginProvider::createPlugin(const Common::FilesystemNode &node) const {
|
||||||
return new Win32Plugin(filename);
|
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
|
// Check the plugin suffix
|
||||||
|
Common::String filename = node.getName();
|
||||||
if (!filename.hasSuffix(".dll"))
|
if (!filename.hasSuffix(".dll"))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
|
@ -32,9 +32,9 @@
|
||||||
|
|
||||||
class Win32PluginProvider : public FilePluginProvider {
|
class Win32PluginProvider : public FilePluginProvider {
|
||||||
protected:
|
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 {}
|
virtual void addCustomDirectories(Common::StringList &dirs) const {}
|
||||||
};
|
};
|
||||||
|
|
|
@ -231,8 +231,8 @@ PluginList FilePluginProvider::getPlugins() {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Common::FSList::const_iterator i = files.begin(); i != files.end(); ++i) {
|
for (Common::FSList::const_iterator i = files.begin(); i != files.end(); ++i) {
|
||||||
if (isPluginFilename(i->getName())) {
|
if (isPluginFilename(*i)) {
|
||||||
pl.push_back(createPlugin(i->getPath()));
|
pl.push_back(createPlugin(*i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -240,7 +240,9 @@ PluginList FilePluginProvider::getPlugins() {
|
||||||
return pl;
|
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
|
#ifdef PLUGIN_PREFIX
|
||||||
// Check the plugin prefix
|
// Check the plugin prefix
|
||||||
if (!filename.hasPrefix(PLUGIN_PREFIX))
|
if (!filename.hasPrefix(PLUGIN_PREFIX))
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
|
|
||||||
namespace Common {
|
namespace Common {
|
||||||
class FSList;
|
class FSList;
|
||||||
|
class FilesystemNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -238,19 +239,19 @@ protected:
|
||||||
* Subclasses of FilePluginProvider have to at least overload this method.
|
* 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.
|
* 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.
|
* @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
|
* Check if the supplied file corresponds to a loadable plugin file in
|
||||||
* the current platform.
|
* 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
|
* @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
|
* Optionally add to the list of directories to be searched for
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue