mirror of
https://github.com/lostjared/Acid.Cam.v2.Qt.git
synced 2025-12-13 18:30:02 +01:00
changed to use Qt directory class
This commit is contained in:
@@ -1,50 +1,31 @@
|
|||||||
#include "plugin.h"
|
#include "plugin.h"
|
||||||
#if defined(__linux__) || defined(__APPLE__)
|
|
||||||
#include<dirent.h>
|
|
||||||
#include<sys/stat.h>
|
|
||||||
#else
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
PluginList plugins;
|
PluginList plugins;
|
||||||
|
|
||||||
#if defined(__linux__) || defined(__APPLE__)
|
void add_directory(QDir &cdir, std::vector<std::string> &files) {
|
||||||
void add_directory(std::string path, std::vector<std::string> &files) {
|
cdir.setFilter(QDir::Files | QDir::Dirs);
|
||||||
DIR *dir = opendir(path.c_str());
|
QFileInfoList list = cdir.entryInfoList();
|
||||||
if(dir == NULL) {
|
int pos = 0;
|
||||||
std::cerr << "Error could not open directory: " << path << "\n";
|
while(pos < list.size()) {
|
||||||
return;
|
QFileInfo info = list.at(pos);
|
||||||
}
|
if(info.isDir() && info.fileName() != "." && info.fileName() != "..") {
|
||||||
dirent *file_info;
|
QDir cdir = info.dir();
|
||||||
while( (file_info = readdir(dir)) != 0 ) {
|
cdir.cd(info.fileName());
|
||||||
std::string f_info = file_info->d_name;
|
add_directory(cdir, files);
|
||||||
if(f_info == "." || f_info == "..") continue;
|
++pos;
|
||||||
std::string fullpath=path+"/"+f_info;
|
|
||||||
struct stat s;
|
|
||||||
|
|
||||||
lstat(fullpath.c_str(), &s);
|
|
||||||
if(S_ISDIR(s.st_mode)) {
|
|
||||||
if(f_info.length()>0 && f_info[0] != '.')
|
|
||||||
add_directory(path+"/"+f_info, files);
|
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(f_info.length()>0 && f_info[0] != '.' && fullpath.rfind(".so") != std::string::npos) {
|
else if(info.isFile() && info.fileName() != "." && info.fileName() != ".." && info.fileName().contains(".so")) {
|
||||||
files.push_back(fullpath);
|
files.push_back(info.filePath().toStdString());
|
||||||
std::cout << "found: " << fullpath << "\n";
|
|
||||||
}
|
}
|
||||||
|
++pos;
|
||||||
}
|
}
|
||||||
closedir(dir);
|
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
void add_directory(std::string path, std::vector<std::string> &files) {
|
|
||||||
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void init_plugins() {
|
void init_plugins() {
|
||||||
std::vector<std::string> files;
|
std::vector<std::string> files;
|
||||||
add_directory("plugins", files);
|
QDir d("plugins");
|
||||||
|
add_directory(d, files);
|
||||||
if(files.size()>0) {
|
if(files.size()>0) {
|
||||||
for(unsigned int i = 0; i < files.size(); ++i) {
|
for(unsigned int i = 0; i < files.size(); ++i) {
|
||||||
Plugin *p = new Plugin();
|
Plugin *p = new Plugin();
|
||||||
|
|||||||
@@ -26,6 +26,8 @@
|
|||||||
#include<QPainter>
|
#include<QPainter>
|
||||||
#include<QWaitCondition>
|
#include<QWaitCondition>
|
||||||
#include<QLibrary>
|
#include<QLibrary>
|
||||||
|
#include<QDir>
|
||||||
|
#include<QFile>
|
||||||
#include"ac.h"
|
#include"ac.h"
|
||||||
#include"fractal.h"
|
#include"fractal.h"
|
||||||
#include<unordered_map>
|
#include<unordered_map>
|
||||||
|
|||||||
Reference in New Issue
Block a user