Skip to content

Commit 5302799

Browse files
committed
Fix: dirent symbols for OSX.
1 parent 619d619 commit 5302799

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

src/c.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
#include <sys/stat.h>
22
#include <dirent.h>
33

4+
#ifdef __APPLE__
5+
DIR * opendir$INODE64( const char * dirName );
6+
struct dirent * readdir$INODE64( DIR * dir );
7+
#endif
8+
49
int c_is_dir(const char *path)
510
{
611
struct stat m;
@@ -12,3 +17,25 @@ const char *get_d_name(struct dirent *d)
1217
{
1318
return (const char *) d->d_name;
1419
}
20+
21+
22+
23+
DIR *c_opendir(const char *dirname){
24+
25+
#ifdef __APPLE__
26+
return opendir$INODE64(dirname);
27+
#else
28+
return opendir(dirname);
29+
#endif
30+
31+
}
32+
33+
struct dirent *c_readdir(DIR *dirp){
34+
35+
#ifdef __APPLE__
36+
return readdir$INODE64(dirp);
37+
#else
38+
return readdir(dirp);
39+
#endif
40+
41+
}

src/fpm_filesystem.F90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ module fpm_filesystem
1919

2020
#ifndef FPM_BOOTSTRAP
2121
interface
22-
function c_opendir(dir) result(r) bind(c, name="opendir")
22+
function c_opendir(dir) result(r) bind(c, name="c_opendir")
2323
import c_char, c_ptr
2424
character(kind=c_char), intent(in) :: dir(*)
2525
type(c_ptr) :: r
2626
end function c_opendir
2727

28-
function c_readdir(dir) result(r) bind(c, name="readdir")
28+
function c_readdir(dir) result(r) bind(c, name="c_readdir")
2929
import c_ptr
3030
type(c_ptr), intent(in), value :: dir
3131
type(c_ptr) :: r

0 commit comments

Comments
 (0)