better
This commit is contained in:
parent
0964470f67
commit
625a2b1d12
2 changed files with 4 additions and 4 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue