X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=cbits%2FdirUtils.c;h=6bc8ad62646b80c1d6cccceca3bcc079f3f829db;hb=c5671f9528f9814e1ce252feb704940eb87b405b;hp=8e87db313f35bda4a811a591ba7b2d6b292e1832;hpb=a7af7ce0e320341ef49115ec2ab74bb21b743544;p=ghc-base.git diff --git a/cbits/dirUtils.c b/cbits/dirUtils.c index 8e87db3..6bc8ad6 100644 --- a/cbits/dirUtils.c +++ b/cbits/dirUtils.c @@ -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 -} -