Move directory-related stuff to the unix package
authorSimon Marlow <marlowsd@gmail.com>
Thu, 25 Jun 2009 12:03:25 +0000 (12:03 +0000)
committerSimon Marlow <marlowsd@gmail.com>
Thu, 25 Jun 2009 12:03:25 +0000 (12:03 +0000)
now that it isn't used on Windows any more.

System/Posix/Internals.hs
aclocal.m4
base.cabal
cbits/dirUtils.c [deleted file]
configure.ac
include/HsBase.h
include/dirUtils.h [deleted file]

index bfa5b2b..85e716c 100644 (file)
@@ -63,14 +63,12 @@ import DIOError
 #endif
 
 #ifdef __HUGS__
-{-# CFILES cbits/PrelIOUtils.c cbits/dirUtils.c cbits/consUtils.c #-}
+{-# CFILES cbits/PrelIOUtils.c cbits/consUtils.c #-}
 #endif
 
 -- ---------------------------------------------------------------------------
 -- Types
 
-type CDir       = ()
-type CDirent    = ()
 type CFLock     = ()
 type CGroup     = ()
 type CLconv     = ()
@@ -363,9 +361,6 @@ foreign import ccall unsafe "HsBase.h chmod"
 foreign import ccall unsafe "HsBase.h close"
    c_close :: CInt -> IO CInt
 
-foreign import ccall unsafe "HsBase.h closedir" 
-   c_closedir :: Ptr CDir -> IO CInt
-
 foreign import ccall unsafe "HsBase.h creat"
    c_creat :: CString -> CMode -> IO CInt
 
@@ -395,21 +390,12 @@ foreign import ccall unsafe "HsBase.h __hscore_lstat"
 foreign import ccall unsafe "__hscore_open"
    c_open :: CFilePath -> CInt -> CMode -> IO CInt
 
-foreign import ccall unsafe "HsBase.h opendir" 
-   c_opendir :: CString  -> IO (Ptr CDir)
-
-foreign import ccall unsafe "HsBase.h __hscore_mkdir"
-   mkdir :: CString -> CInt -> IO CInt
-
 foreign import ccall unsafe "HsBase.h read" 
    c_read :: CInt -> Ptr Word8 -> CSize -> IO CSsize
 
 foreign import ccall safe "read"
    c_safe_read :: CInt -> Ptr Word8 -> CSize -> IO CSsize
 
-foreign import ccall unsafe "HsBase.h rewinddir"
-   c_rewinddir :: Ptr CDir -> IO ()
-
 foreign import ccall unsafe "__hscore_stat"
    c_stat :: CFilePath -> Ptr CStat -> IO CInt
 
@@ -475,19 +461,6 @@ foreign import ccall unsafe "HsBase.h waitpid"
    c_waitpid :: CPid -> Ptr CInt -> CInt -> IO CPid
 #endif
 
--- traversing directories
-foreign import ccall unsafe "dirUtils.h __hscore_readdir"
-  readdir  :: Ptr CDir -> Ptr (Ptr CDirent) -> IO CInt
-foreign import ccall unsafe "HsBase.h __hscore_free_dirent"
-  freeDirEnt  :: Ptr CDirent -> IO ()
-foreign import ccall unsafe "HsBase.h __hscore_end_of_dir"
-  end_of_dir :: CInt
-foreign import ccall unsafe "HsBase.h __hscore_d_name"
-  d_name :: Ptr CDirent -> IO CString
-
 -- POSIX flags only:
 foreign import ccall unsafe "HsBase.h __hscore_o_rdonly" o_RDONLY :: CInt
 foreign import ccall unsafe "HsBase.h __hscore_o_wronly" o_WRONLY :: CInt
index d40392a..e95a970 100644 (file)
@@ -169,66 +169,6 @@ undefine([AC_CV_NAME_supported])dnl
 ])
 
 
-# FP_READDIR_EOF_ERRNO
-# --------------------
-# Defines READDIR_ERRNO_EOF to what readdir() sets 'errno' to upon reaching end
-# of directory (not set => 0); not setting it is the correct thing to do, but
-# MinGW based versions have set it to ENOENT until recently (summer 2004).
-AC_DEFUN([FP_READDIR_EOF_ERRNO],
-[AC_CACHE_CHECK([what readdir sets errno to upon EOF], [fptools_cv_readdir_eof_errno],
-[AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <dirent.h>
-#include <stdio.h>
-#include <errno.h>
-#include <sys/stat.h>
-
-int
-main(argc, argv)
-int argc;
-char **argv;
-{
-  FILE *f=fopen("conftestval", "w");
-#if defined(__MINGW32__)
-  int fd = mkdir("testdir");
-#else
-  int fd = mkdir("testdir", 0666);
-#endif
-  DIR* dp;
-  struct dirent* de;
-  int err = 0;
-
-  if (!f) return 1;
-  if (fd == -1) { 
-     fprintf(stderr,"unable to create directory; quitting.\n");
-     return 1;
-  }
-  close(fd);
-  dp = opendir("testdir");
-  if (!dp) { 
-     fprintf(stderr,"unable to browse directory; quitting.\n");
-     rmdir("testdir");
-     return 1;
-  }
-
-  /* the assumption here is that readdir() will only return NULL
-   * due to reaching the end of the directory.
-   */
-  while (de = readdir(dp)) {
-       ;
-  }
-  err = errno;
-  fprintf(f,"%d", err);
-  fclose(f);
-  closedir(dp);
-  rmdir("testdir");
-  return 0;
-}]])],
-[fptools_cv_readdir_eof_errno=`cat conftestval`],
-[AC_MSG_WARN([failed to determine the errno value])
- fptools_cv_readdir_eof_errno=0],
-[fptools_cv_readdir_eof_errno=0])])
-AC_DEFINE_UNQUOTED([READDIR_ERRNO_EOF], [$fptools_cv_readdir_eof_errno], [readdir() sets errno to this upon EOF])
-])# FP_READDIR_EOF_ERRNO
-
 # FP_SEARCH_LIBS_PROTO(WHAT, PROTOTYPE, FUNCTION, SEARCH-LIBS,
 #                [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
 #                [OTHER-LIBRARIES])
@@ -263,4 +203,3 @@ AS_IF([test "$ac_res" != no],
       [$6])dnl
 AS_VAR_POPDEF([ac_Search])dnl
 ])
-
index 1ee6f30..032010d 100644 (file)
@@ -187,12 +187,11 @@ Library {
         cbits/WCsubst.c
         cbits/Win32Utils.c
         cbits/consUtils.c
-        cbits/dirUtils.c
         cbits/inputReady.c
         cbits/selectUtils.c
     include-dirs: include
     includes:    HsBase.h
-    install-includes:    HsBase.h HsBaseConfig.h WCsubst.h dirUtils.h consUtils.h Typeable.h
+    install-includes:    HsBase.h HsBaseConfig.h WCsubst.h consUtils.h Typeable.h
     if os(windows) {
         extra-libraries: wsock32, user32, shell32
     }
diff --git a/cbits/dirUtils.c b/cbits/dirUtils.c
deleted file mode 100644 (file)
index ed3f9e8..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-/* 
- * (c) The University of Glasgow 2002
- *
- * Directory Runtime Support
- */
-
-/* needed only for solaris2_HOST_OS */
-#ifdef __GLASGOW_HASKELL__
-#include "ghcconfig.h"
-#endif
-
-// The following is required on Solaris to force the POSIX versions of
-// the various _r functions instead of the Solaris versions.
-#ifdef solaris2_HOST_OS
-#define _POSIX_PTHREAD_SEMANTICS
-#endif
-
-#include "HsBase.h"
-
-#if defined(_MSC_VER) || defined(__MINGW32__) || defined(_WIN32)
-#include <windows.h>
-#endif
-
-
-/*
- * read an entry from the directory stream; opt for the
- * re-entrant friendly way of doing this, if available.
- */
-int
-__hscore_readdir( DIR *dirPtr, struct dirent **pDirEnt )
-{
-#if HAVE_READDIR_R
-  struct dirent* p;
-  int res;
-  static unsigned int nm_max = (unsigned int)-1;
-  
-  if (pDirEnt == NULL) {
-    return -1;
-  }
-  if (nm_max == (unsigned int)-1) {
-#ifdef NAME_MAX
-    nm_max = NAME_MAX + 1;
-#else
-    nm_max = pathconf(".", _PC_NAME_MAX);
-    if (nm_max == -1) { nm_max = 255; }
-    nm_max++;
-#endif
-  }
-  p = (struct dirent*)malloc(sizeof(struct dirent) + nm_max);
-  if (p == NULL) return -1;
-  res = readdir_r(dirPtr, p, pDirEnt);
-  if (res != 0) {
-      *pDirEnt = NULL;
-      free(p);
-  }
-  else if (*pDirEnt == NULL) {
-    // end of stream
-    free(p);
-  }
-  return res;
-#else
-
-  if (pDirEnt == NULL) {
-    return -1;
-  }
-
-  *pDirEnt = readdir(dirPtr);
-  if (*pDirEnt == NULL) {
-    return -1;
-  } else {
-    return 0;
-  }  
-#endif
-}
index 0a28124..91c72a5 100644 (file)
@@ -17,7 +17,7 @@ dnl ** check for full ANSI header (.h) files
 AC_HEADER_STDC
 
 # check for specific header (.h) files that we are interested in
-AC_CHECK_HEADERS([ctype.h dirent.h errno.h fcntl.h inttypes.h limits.h signal.h sys/resource.h sys/select.h sys/stat.h sys/syscall.h sys/time.h sys/timeb.h sys/timers.h sys/times.h sys/types.h sys/utsname.h sys/wait.h termios.h time.h unistd.h utime.h windows.h winsock.h langinfo.h])
+AC_CHECK_HEADERS([ctype.h errno.h fcntl.h inttypes.h limits.h signal.h sys/resource.h sys/select.h sys/stat.h sys/syscall.h sys/time.h sys/timeb.h sys/timers.h sys/times.h sys/types.h sys/utsname.h sys/wait.h termios.h time.h unistd.h utime.h windows.h winsock.h langinfo.h])
 
 # Enable large file support. Do this before testing the types ino_t, off_t, and
 # rlim_t, because it will affect the result of that test.
@@ -28,7 +28,7 @@ dnl FreeBSD has an emtpy wctype.h, so test one of the affected
 dnl functions if it's really there.
 AC_CHECK_HEADERS([wctype.h], [AC_CHECK_FUNCS(iswspace)])
 
-AC_CHECK_FUNCS([lstat readdir_r])
+AC_CHECK_FUNCS([lstat])
 AC_CHECK_FUNCS([getclock getrusage times])
 AC_CHECK_FUNCS([_chsize ftruncate])
 
@@ -96,9 +96,6 @@ FP_CHECK_CONSTS([SIGINT], [
 dnl ** can we open files in binary mode?
 FP_CHECK_CONST([O_BINARY], [#include <fcntl.h>], [0])
 
-# Check for idiosyncracies in some mingw impls of directory handling.
-FP_READDIR_EOF_ERRNO
-
 # We can't just use AC_SEARCH_LIBS for this, as on OpenBSD the iconv.h
 # header needs to be included as iconv_open is #define'd to something
 # else. We therefore use our own FP_SEARCH_LIBS_PROTO, which allows us
index 92cc4e3..e052918 100644 (file)
@@ -62,9 +62,6 @@
 #if HAVE_STRING_H
 #include <string.h>
 #endif
-#if HAVE_DIRENT_H
-#include <dirent.h>
-#endif
 #if HAVE_UTIME_H
 #include <utime.h>
 #endif
 #if HAVE_VFORK_H
 #include <vfork.h>
 #endif
-#include "dirUtils.h"
 #include "WCsubst.h"
 
 #if defined(__MINGW32__)
@@ -419,36 +415,6 @@ __hscore_setmode( int fd, HsBool toBin )
 
 #endif /* __GLASGOW_HASKELL__ */
 
-INLINE int
-__hscore_mkdir( char *pathName, int mode )
-{
-#if defined(_MSC_VER) || defined(__MINGW32__) || defined(_WIN32)
-  return mkdir(pathName);
-#else
-  return mkdir(pathName,mode);
-#endif
-}
-
-INLINE char *
-__hscore_d_name( struct dirent* d )
-{
-  return (d->d_name);
-}
-
-INLINE int
-__hscore_end_of_dir( void )
-{
-  return READDIR_ERRNO_EOF;
-}
-
-INLINE void
-__hscore_free_dirent(struct dirent *dEnt)
-{
-#if HAVE_READDIR_R
-  free(dEnt);
-#endif
-}
-
 #if defined(__MINGW32__)
 // We want the versions of stat/fstat/lseek that use 64-bit offsets,
 // and you have to ask for those explicitly.  Unfortunately there
diff --git a/include/dirUtils.h b/include/dirUtils.h
deleted file mode 100644 (file)
index 87a3041..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-/* 
- * (c) The University of Glasgow 2002
- *
- * Directory Runtime Support
- */
-#ifndef __DIRUTILS_H__
-#define __DIRUTILS_H__
-#include <sys/types.h>
-#include <dirent.h>
-
-extern int __hscore_readdir(DIR *dirPtr, struct dirent **pDirEnt);
-
-#endif /* __DIRUTILS_H__ */