mirror of
https://github.com/Team-Neptune/DeepSea-Updater.git
synced 2024-11-23 04:19:47 +00:00
changed to a recursive dir iterator! first try!
This commit is contained in:
parent
4a152bb910
commit
4c2bb09984
@ -100,9 +100,9 @@ namespace dsu
|
||||
return false;
|
||||
}
|
||||
|
||||
vector<string> FileManager::getExistingFiles(string path)
|
||||
// This scans all FILES in the given directory and it's respective subdirs.
|
||||
vector<string> FileManager::scanDirectoryRecursive(string path)
|
||||
{
|
||||
DIR *dir;
|
||||
vector<string> files;
|
||||
|
||||
// First check if the dir even exists.
|
||||
@ -110,22 +110,16 @@ namespace dsu
|
||||
{
|
||||
// Then make sure it's actually a directory, and not a file. All before
|
||||
// iterating all of the files in the directory.
|
||||
dir = opendir(path.c_str());
|
||||
if(dir != NULL)
|
||||
if(fs::is_directory(path))
|
||||
{
|
||||
for (auto ft : fs::directory_iterator(path))
|
||||
for (auto ft : fs::recursive_directory_iterator(path))
|
||||
{
|
||||
// Check if the fs in question is a dir (we don't want to list dirs, only files).
|
||||
if(ft.is_directory()) continue;
|
||||
|
||||
string file = ft.path().filename().string();;
|
||||
|
||||
files.push_back(file);
|
||||
if(ft.is_directory()) continue;
|
||||
string path = ft.path().string();
|
||||
|
||||
files.push_back(path);
|
||||
}
|
||||
}
|
||||
|
||||
closedir(dir);
|
||||
|
||||
return files;
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ namespace dsu {
|
||||
static bool deleteFile(std::string filename);
|
||||
static bool appendFile(std::string filename, std::string data);
|
||||
static bool fileExists(std::string filename);
|
||||
static std::vector<std::string> getExistingFiles(std::string path);
|
||||
static std::vector<std::string> scanDirectoryRecursive(std::string path);
|
||||
static bool createSubfolder(std::string path);
|
||||
static bool extract(std::string filename, std::string destination);
|
||||
static void cleanUpFiles();
|
||||
|
@ -37,6 +37,13 @@ int main(int argc, char **argv)
|
||||
|
||||
nxlinkStdio();
|
||||
|
||||
vector<string> f = FileManager::scanDirectoryRecursive("sdmc:/config");
|
||||
|
||||
for (auto i : f)
|
||||
{
|
||||
cout << i << '\n';
|
||||
}
|
||||
|
||||
ConfigManager::initialize();
|
||||
|
||||
if (ConfigManager::shouldUseProxy()) {
|
||||
|
Loading…
Reference in New Issue
Block a user