Skip to content

Commit 6424a78

Browse files
TerrorJackRufflewind
authored andcommitted
Check for realpath function in autoconf
In case it doesn't exist (e.g. in wasi-libc), c_realpath should throw an exception.
1 parent e75648d commit 6424a78

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

System/Directory/Internal/Posix.hsc

+9
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,17 @@ c_PATH_MAX | c_PATH_MAX' > toInteger maxValue = Nothing
4949
c_PATH_MAX = Nothing
5050
#endif
5151

52+
#if !defined(HAVE_REALPATH)
53+
54+
c_realpath :: CString -> CString -> IO CString
55+
c_realpath _ _ = throwIO (mkIOError UnsupportedOperation "platform does not support realpath" Nothing Nothing)
56+
57+
#else
58+
5259
foreign import ccall "realpath" c_realpath :: CString -> CString -> IO CString
5360

61+
#endif
62+
5463
withRealpath :: CString -> (CString -> IO a) -> IO a
5564
withRealpath path action = case c_PATH_MAX of
5665
Nothing ->

configure.ac

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ AC_PROG_CC()
3030
# check for specific header (.h) files that we are interested in
3131
AC_CHECK_HEADERS([fcntl.h limits.h sys/types.h sys/stat.h time.h])
3232

33+
AC_CHECK_FUNCS([realpath])
3334
AC_CHECK_FUNCS([utimensat])
3435
AC_CHECK_FUNCS([CreateSymbolicLinkW])
3536
AC_CHECK_FUNCS([GetFinalPathNameByHandleW])

0 commit comments

Comments
 (0)