diff options
author | ross <unknown> | 2003-09-02 16:07:11 +0000 |
---|---|---|
committer | ross <unknown> | 2003-09-02 16:07:11 +0000 |
commit | 03bef664f96be784f01b8e9d0300ae0098bb4394 (patch) | |
tree | 110032cf5ed140c36e1ec656cd1c896984263003 | |
parent | f0be11eb5b30da46f5e7ef5c28b23b82654b96b3 (diff) | |
download | haskell-03bef664f96be784f01b8e9d0300ae0098bb4394.tar.gz |
[project @ 2003-09-02 16:07:08 by ross]
Deal with systems on which PATH_MAX is undefined, e.g. systems with
unlimited path length, like the Hurd (also faulty installations of gcc
on Solaris). In fact getCurrentDirectory only needs a long path size
to use as a first approximation, so give it that.
-rw-r--r-- | libraries/base/System/Directory.hs | 8 | ||||
-rw-r--r-- | libraries/base/include/HsBase.h | 12 |
2 files changed, 14 insertions, 6 deletions
diff --git a/libraries/base/System/Directory.hs b/libraries/base/System/Directory.hs index f4e18078db..734ed94987 100644 --- a/libraries/base/System/Directory.hs +++ b/libraries/base/System/Directory.hs @@ -517,8 +517,8 @@ The operating system has no notion of current directory. getCurrentDirectory :: IO FilePath getCurrentDirectory = do - p <- mallocBytes path_max - go p path_max + p <- mallocBytes long_path_size + go p long_path_size where go p bytes = do p' <- c_getcwd p (fromIntegral bytes) if p' /= nullPtr @@ -651,8 +651,8 @@ unionCMode :: CMode -> CMode -> CMode unionCMode = (+) -foreign import ccall unsafe "__hscore_path_max" - path_max :: Int +foreign import ccall unsafe "__hscore_long_path_size" + long_path_size :: Int foreign import ccall unsafe "__hscore_R_OK" r_OK :: CMode foreign import ccall unsafe "__hscore_W_OK" w_OK :: CMode diff --git a/libraries/base/include/HsBase.h b/libraries/base/include/HsBase.h index e5be148183..5251dc8890 100644 --- a/libraries/base/include/HsBase.h +++ b/libraries/base/include/HsBase.h @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: HsBase.h,v 1.24 2003/08/20 15:54:45 panne Exp $ + * $Id: HsBase.h,v 1.25 2003/09/02 16:07:11 ross Exp $ * * (c) The University of Glasgow 2001-2002 * @@ -427,7 +427,15 @@ __hscore_lstat( HsAddr fname, HsAddr st ) #endif } -INLINE HsInt __hscore_path_max() { return PATH_MAX; } +#ifdef PATH_MAX +/* A size that will contain many path names, but not necessarily all + * (PATH_MAX is not defined on systems with unlimited path length, + * e.g. the Hurd). + */ +INLINE HsInt __hscore_long_path_size() { return PATH_MAX; } +#else +INLINE HsInt __hscore_long_path_size() { return 4096; } +#endif INLINE mode_t __hscore_R_OK() { return R_OK; } INLINE mode_t __hscore_W_OK() { return W_OK; } |