Proper folder / file distinction in plugin loading.
This commit is contained in:
parent
403e0d5be4
commit
edd7363edd
@ -287,6 +287,20 @@ bool cFile::Rename(const AString & a_OrigFileName, const AString & a_NewFileName
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool cFile::IsFolder(const AString & a_Path)
|
||||||
|
{
|
||||||
|
#ifdef _WIN32
|
||||||
|
return ((GetFileAttributes(a_Path.c_str()) & FILE_ATTRIBUTE_DIRECTORY) != 0);
|
||||||
|
#else
|
||||||
|
struct stat st;
|
||||||
|
return ((stat(a_Path.c_str(), &st) == 0) && S_ISDIR(st.st_mode));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int cFile::Printf(const char * a_Fmt, ...)
|
int cFile::Printf(const char * a_Fmt, ...)
|
||||||
{
|
{
|
||||||
AString buf;
|
AString buf;
|
||||||
|
@ -99,6 +99,9 @@ public:
|
|||||||
/// Renames a file, returns true if successful. May fail if dest already exists (libc-dependant)!
|
/// Renames a file, returns true if successful. May fail if dest already exists (libc-dependant)!
|
||||||
static bool Rename(const AString & a_OrigFileName, const AString & a_NewFileName);
|
static bool Rename(const AString & a_OrigFileName, const AString & a_NewFileName);
|
||||||
|
|
||||||
|
/// Returns true if the specified path is a folder
|
||||||
|
static bool IsFolder(const AString & a_Path);
|
||||||
|
|
||||||
int Printf(const char * a_Fmt, ...);
|
int Printf(const char * a_Fmt, ...);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -75,9 +75,9 @@ void cPluginManager::FindPlugins(void)
|
|||||||
AStringList Files = GetDirectoryContents(PluginsPath.c_str());
|
AStringList Files = GetDirectoryContents(PluginsPath.c_str());
|
||||||
for (AStringList::const_iterator itr = Files.begin(); itr != Files.end(); ++itr)
|
for (AStringList::const_iterator itr = Files.begin(); itr != Files.end(); ++itr)
|
||||||
{
|
{
|
||||||
if (itr->rfind(".") != AString::npos)
|
if (!cFile::IsFolder(*itr))
|
||||||
{
|
{
|
||||||
// Ignore files, we only want directories
|
// We only want folders
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user