mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-05 21:57:20 +00:00
Implement base::list_files() for Unix-like platforms
This commit is contained in:
parent
98f2aca5ca
commit
1edb21ca4e
@ -4,13 +4,15 @@
|
||||
// This file is released under the terms of the MIT license.
|
||||
// Read LICENSE.txt for more information.
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <dirent.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <cstdlib>
|
||||
#include <ctime>
|
||||
#include <stdexcept>
|
||||
#include <vector>
|
||||
#include <ctime>
|
||||
|
||||
#if __APPLE__
|
||||
#include <mach-o/dyld.h>
|
||||
@ -143,4 +145,21 @@ std::string get_user_docs_folder()
|
||||
return "/";
|
||||
}
|
||||
|
||||
std::vector<std::string> list_files(const std::string& path)
|
||||
{
|
||||
std::vector<std::string> files;
|
||||
DIR* handle = opendir(path.c_str());
|
||||
if (handle) {
|
||||
dirent* item;
|
||||
while ((item = readdir(handle)) != nullptr) {
|
||||
std::string filename = item->d_name;
|
||||
if (filename != "." && filename != "..")
|
||||
files.push_back(filename);
|
||||
}
|
||||
|
||||
closedir(handle);
|
||||
}
|
||||
return files;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user