-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPluginEnumerator.cpp
52 lines (46 loc) · 1.28 KB
/
PluginEnumerator.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include "PluginEnumerator.h"
#include <dirent.h>
#include <iostream>
#include <string>
#define MAX_D_NAME_LENGTH 256 /*最大路径字符长度*/
PluginEnumerator::PluginEnumerator(/* args */)
{
}
PluginEnumerator::~PluginEnumerator()
{
}
/**
* @brief get plugin path in plugin directory
*
* @param vStrPlugin save plugin path
* @return true
* @return false
*/
bool PluginEnumerator::GetPluginNames(vector<string> &vStrPlugin)
{
DIR *dir; //目录流对象的数据类型指针
struct dirent *ptr; //目录项结构体指针
char *path = (char *)"./plugin"; //open directory plugin
//char *curr_path;//[MAX_D_NAME_LENGTH]; // current directory
dir = opendir(path); //open directory
// chack if the directory exists
if (dir == NULL)
{
cout << "There's not exist directory called plugin" << endl;
return false;
}
while ((ptr = readdir(dir)) != NULL)
{
if (ptr->d_name[0] == '.')
{
//剔除隐藏文件和文件自身,保证文件隐藏和打印效果
continue;
}
/* 手动处理文件夹路径 */
string str = "./plugin/";
str += ptr->d_name;
vStrPlugin.push_back(str);
}
closedir(dir);
return true;
}