-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #507 from brocolis/file-listing
optimize file listing
- Loading branch information
Showing
4 changed files
with
232 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#include <sys/stat.h> | ||
#include <dirent.h> | ||
|
||
#ifdef __APPLE__ | ||
DIR * opendir$INODE64( const char * dirName ); | ||
struct dirent * readdir$INODE64( DIR * dir ); | ||
#endif | ||
|
||
int c_is_dir(const char *path) | ||
{ | ||
struct stat m; | ||
int r = stat(path, &m); | ||
return r == 0 && S_ISDIR(m.st_mode); | ||
} | ||
|
||
const char *get_d_name(struct dirent *d) | ||
{ | ||
return (const char *) d->d_name; | ||
} | ||
|
||
|
||
|
||
DIR *c_opendir(const char *dirname){ | ||
|
||
#ifdef __APPLE__ | ||
return opendir$INODE64(dirname); | ||
#else | ||
return opendir(dirname); | ||
#endif | ||
|
||
} | ||
|
||
struct dirent *c_readdir(DIR *dirp){ | ||
|
||
#ifdef __APPLE__ | ||
return readdir$INODE64(dirp); | ||
#else | ||
return readdir(dirp); | ||
#endif | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters