use dir_reader for Plugins::FindCommands
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@4153 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
2c00a558bf
commit
0d1e06dd2d
1 changed files with 14 additions and 59 deletions
|
@ -4,12 +4,12 @@
|
||||||
#include "Plugins.h"
|
#include "Plugins.h"
|
||||||
#include "Platform.h"
|
#include "Platform.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "dirreader.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
# include <WinNT.h>
|
# include <WinNT.h>
|
||||||
#else
|
#else
|
||||||
# include <sys/stat.h>
|
# include <sys/stat.h>
|
||||||
# include <glob.h>
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern FILE *g_output;
|
extern FILE *g_output;
|
||||||
|
@ -48,70 +48,25 @@ void PluginsList::setDataHandle(const char *name, int dataHandle, int uninstData
|
||||||
|
|
||||||
void Plugins::FindCommands(char* path, bool displayInfo)
|
void Plugins::FindCommands(char* path, bool displayInfo)
|
||||||
{
|
{
|
||||||
if (path)
|
if (!path)
|
||||||
{
|
return;
|
||||||
int length = strlen(path);
|
|
||||||
|
|
||||||
if (length > 0)
|
dir_reader *dr = new_dir_reader();
|
||||||
{
|
dr->read(path);
|
||||||
char *lc = CharPrev(path, path + strlen(path));
|
|
||||||
if (*lc == '\\' || *lc == '/')
|
|
||||||
{
|
|
||||||
length--;
|
|
||||||
}
|
|
||||||
|
|
||||||
char* basePath = new char [length+1];
|
dir_reader::iterator files_itr = dr->files().begin();
|
||||||
strncpy(basePath,path,length);
|
dir_reader::iterator files_end = dr->files().end();
|
||||||
basePath[length] = 0;
|
|
||||||
|
|
||||||
char* pathAndWildcard = new char [length+7];
|
for (; files_itr != files_end; files_itr++) {
|
||||||
strcpy(pathAndWildcard,basePath);
|
if (!dir_reader::matches(*files_itr, "*.dll"))
|
||||||
strcat(pathAndWildcard,PLATFORM_PATH_SEPARATOR_STR "*.dll");
|
continue;
|
||||||
|
|
||||||
#ifdef _WIN32
|
string plugin = string(path) + PLATFORM_PATH_SEPARATOR_C + *files_itr;
|
||||||
WIN32_FIND_DATA data;
|
|
||||||
HANDLE handle;
|
|
||||||
|
|
||||||
handle = FindFirstFile(pathAndWildcard,&data);
|
GetExports((char *) plugin.c_str(), displayInfo);
|
||||||
if (handle != INVALID_HANDLE_VALUE)
|
|
||||||
{
|
|
||||||
do
|
|
||||||
#else
|
|
||||||
glob_t globbuf;
|
|
||||||
globbuf.gl_offs = 0;
|
|
||||||
globbuf.gl_pathc = 0;
|
|
||||||
if (!glob(pathAndWildcard, 0, NULL, &globbuf))
|
|
||||||
{
|
|
||||||
struct stat s;
|
|
||||||
for (unsigned int i = 0; i < globbuf.gl_pathc; i++)
|
|
||||||
{
|
|
||||||
if (stat(globbuf.gl_pathv[i], &s) || !S_ISREG(s.st_mode))
|
|
||||||
continue;
|
|
||||||
#endif
|
|
||||||
#ifdef _WIN32
|
|
||||||
{
|
|
||||||
char* dllPath = new char [length+strlen(data.cFileName)+2];
|
|
||||||
wsprintf(dllPath,"%s" PLATFORM_PATH_SEPARATOR_STR "%s",basePath,data.cFileName);
|
|
||||||
#else
|
|
||||||
char *dllPath = new char [strlen(globbuf.gl_pathv[i])+1];
|
|
||||||
strcpy(dllPath,globbuf.gl_pathv[i]);
|
|
||||||
#endif
|
|
||||||
GetExports(dllPath,displayInfo);
|
|
||||||
delete[] dllPath;
|
|
||||||
}
|
|
||||||
#ifdef _WIN32
|
|
||||||
while (FindNextFile(handle,&data));
|
|
||||||
#else
|
|
||||||
globfree(&globbuf);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
delete[] pathAndWildcard;
|
|
||||||
#endif
|
|
||||||
delete[] basePath;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete dr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Plugins::GetExports(char* pathToDll, bool displayInfo)
|
void Plugins::GetExports(char* pathToDll, bool displayInfo)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue