diff options
author | Laurence Kedward <laurence.kedward@bristol.ac.uk> | 2021-07-28 15:59:22 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-28 15:59:22 +0100 |
commit | 8ffe495e6097358e98cf45464cdc45b58a31e0fb (patch) | |
tree | ec865ea2200ff27162dcf12b63b79356870c55eb /src/filesystem_utilities.c | |
parent | 9e26b2d66c72c81ac5a0d752528104293836d206 (diff) | |
parent | 18e2dab82c0760c501d4634e935b2ed7a50c26a5 (diff) | |
download | fpm-8ffe495e6097358e98cf45464cdc45b58a31e0fb.tar.gz fpm-8ffe495e6097358e98cf45464cdc45b58a31e0fb.zip |
Merge pull request #507 from brocolis/file-listing
optimize file listing
Diffstat (limited to 'src/filesystem_utilities.c')
-rw-r--r-- | src/filesystem_utilities.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/filesystem_utilities.c b/src/filesystem_utilities.c new file mode 100644 index 0000000..7075f42 --- /dev/null +++ b/src/filesystem_utilities.c @@ -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 + +}
\ No newline at end of file |