Browse Source

Add scratch filesystemListDirectory

tags/v0.6.0
Andrew Belt 6 years ago
parent
commit
b5e1bd4365
2 changed files with 46 additions and 1 deletions
  1. +1
    -0
      .gitignore
  2. +45
    -1
      src/main.cpp

+ 1
- 0
.gitignore View File

@@ -1,5 +1,6 @@
/Rack /Rack
/Rack.exe /Rack.exe
/Rack.res
/libRack.a /libRack.a
/autosave.json /autosave.json
/settings.json /settings.json


+ 45
- 1
src/main.cpp View File

@@ -6,13 +6,57 @@
#include "settings.hpp" #include "settings.hpp"
#include "asset.hpp" #include "asset.hpp"
#include "bridge.hpp" #include "bridge.hpp"
#include <unistd.h>
#include "osdialog.h" #include "osdialog.h"


#include <unistd.h>

#if defined(ARCH_WIN)
#include <windows.h>
#else
#include <glob.h>
#endif



using namespace rack; using namespace rack;



std::vector<std::string> filesystemListDirectory(std::string path) {
std::vector<std::string> filenames;
#if defined(ARCH_WIN)
WIN32_FIND_DATA findData;
HANDLE findHandle = FindFirstFile((path + "/*").c_str(), &findData);
if (findHandle != INVALID_HANDLE_VALUE) {
do {
std::string filename = findData.cFileName;
if (filename == "." || filename == "..")
continue;
filenames.push_back(path + "/" + filename);
} while (FindNextFile(findHandle, &findData));
FindClose(findHandle);
}
#else
DIR *dir = opendir(path.c_str());
if (dir) {
struct dirent *d;
while ((d = readdir(dir))) {
std::string filename = d->f_name;
if (filename == "." || filename == "..")
continue;
filenames.push_back(path + "/" + filename);
}
closedir(dir);
}
#endif
return filenames;
}

int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {

for (std::string filename : filesystemListDirectory("plugins")) {
debug("%s", filename.c_str());
}
return 0;

randomInit(); randomInit();
loggerInit(); loggerInit();




Loading…
Cancel
Save