remove __hscore_renameFile, it is no longer uesd
authorSimon Marlow <marlowsd@gmail.com>
Mon, 18 Aug 2008 15:59:50 +0000 (15:59 +0000)
committerSimon Marlow <marlowsd@gmail.com>
Mon, 18 Aug 2008 15:59:50 +0000 (15:59 +0000)
System.Directory implements renameFile using unix/Win32 now.

System/Posix/Internals.hs
cbits/dirUtils.c
include/dirUtils.h

index 960f84c..5828d72 100644 (file)
@@ -369,9 +369,6 @@ foreign import ccall unsafe "HsBase.h __hscore_mkdir"
 foreign import ccall unsafe "HsBase.h read" 
    c_read :: CInt -> Ptr CChar -> CSize -> IO CSsize
 
-foreign import ccall unsafe "dirUtils.h __hscore_renameFile"
-   c_rename :: CString -> CString -> IO CInt
-                     
 foreign import ccall unsafe "HsBase.h rewinddir"
    c_rewinddir :: Ptr CDir -> IO ()
 
index 8e87db3..6bc8ad6 100644 (file)
@@ -70,71 +70,3 @@ __hscore_readdir( DIR *dirPtr, struct dirent **pDirEnt )
   }  
 #endif
 }
-
-/*
- * Function: __hscore_renameFile()
- *
- * Provide Haskell98's semantics for renaming files and directories.
- * It mirrors that of POSIX.1's behaviour for rename() by overwriting
- * the target if it exists (the MS CRT implementation of rename() returns
- * an error
- *
- */
-int
-__hscore_renameFile( char *src, char *dest)
-{
-#if defined(_MSC_VER) || defined(__MINGW32__) || defined(_WIN32)
-    static int forNT = -1;
-    
-    /* ToDo: propagate error codes back */
-    if (MoveFileA(src, dest)) {
-       return 0;
-    } else {
-       ;
-    }
-    
-    /* Failed...it could be because the target already existed. */
-    if ( !GetFileAttributes(dest) ) {
-       /* No, it's not there - just fail. */
-       maperrno();
-       return (-1);
-    }
-
-    if (forNT == -1) {
-       OSVERSIONINFO ovi;
-       ovi.dwOSVersionInfoSize = sizeof(ovi);
-       if ( !GetVersionEx(&ovi) ) {
-           maperrno();
-           return (-1);
-       }
-       forNT = ((ovi.dwPlatformId & VER_PLATFORM_WIN32_NT) != 0);
-    }
-    
-    if (forNT) {
-       /* Easy, go for MoveFileEx() */
-       if ( MoveFileExA(src, dest, MOVEFILE_REPLACE_EXISTING) ) {
-           return 0;
-       } else {
-           maperrno();
-           return (-1);
-       }
-    }
-
-    /* No MoveFileEx() for Win9x, try deleting the target. */
-    /* Similarly, if the MoveFile*() ops didn't work out under NT */
-    if (DeleteFileA(dest)) {
-       if (MoveFileA(src,dest)) {
-           return 0;
-       } else {
-           maperrno();
-           return (-1);
-       }
-    } else {
-       maperrno();
-       return (-1);
-    }
-#else
-    return rename(src,dest);
-#endif
-}
-
index a5171d8..d5d75bb 100644 (file)
@@ -7,6 +7,5 @@
 #define __DIRUTILS_H__
 
 extern int __hscore_readdir(DIR *dirPtr, struct dirent **pDirEnt);
-extern int __hscore_renameFile(char *src, char *dest);
 
 #endif /* __DIRUTILS_H__ */