This commit is contained in:
Nishi 2025-11-18 17:51:38 +09:00
commit 625a2b1d12
2 changed files with 4 additions and 4 deletions

View file

@ -7,7 +7,7 @@
extern "C" {
#endif
void MDEDirectoryScan(const char* path, void (*call)(const char* name, int dir, void* user), void* user);
void MDEDirectoryScan(const char* path, void (*call)(const char* name, int dir, int symlink, void* user), void* user);
#ifdef __cplusplus
}

View file

@ -5,7 +5,7 @@
#include <dirent.h>
#include <sys/stat.h>
void MDEDirectoryScan(const char* path, void (*call)(const char* name, int dir, void* user), void* user) {
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;
@ -19,8 +19,8 @@ void MDEDirectoryScan(const char* path, void (*call)(const char* name, int dir,
if(path[strlen(path) - 1] != '/') strcat(p, "/");
strcat(p, d->d_name);
if(stat(p, &s) == 0) {
call(p, S_ISDIR(s.st_mode) ? 1 : 0, user);
if(lstat(p, &s) == 0) {
call(p, S_ISDIR(s.st_mode) ? 1 : 0, S_ISLNK(s.st_mode) ? 1 : 0, user);
}
free(p);