layout
This commit is contained in:
parent
1f38fcdc74
commit
760db962ea
12 changed files with 273 additions and 154 deletions
|
|
@ -1,28 +0,0 @@
|
|||
#include <MDE/Core/Directory.h>
|
||||
|
||||
#include <dirent.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
void MDEDirectoryScan(const char* path, void (*call)(const char* name, int dir, int symlink, void* user), void* user) {
|
||||
DIR* dir = opendir(path);
|
||||
if(dir != NULL) {
|
||||
struct dirent* d;
|
||||
while((d = readdir(dir)) != NULL) {
|
||||
char* p;
|
||||
struct stat s;
|
||||
if(strcmp(d->d_name, "..") == 0 || strcmp(d->d_name, ".") == 0) continue;
|
||||
|
||||
p = malloc(strlen(path) + 1 + strlen(d->d_name) + 1);
|
||||
strcpy(p, path);
|
||||
if(path[strlen(path) - 1] != '/') strcat(p, "/");
|
||||
strcat(p, d->d_name);
|
||||
|
||||
if(lstat(p, &s) == 0) {
|
||||
call(p, S_ISDIR(s.st_mode) ? 1 : 0, S_ISLNK(s.st_mode) ? 1 : 0, user);
|
||||
}
|
||||
|
||||
free(p);
|
||||
}
|
||||
closedir(dir);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue