X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=cbits%2FdirUtils.c;h=d6da255a8bca72ca93a1a758afe71164ec2a6845;hb=74bc2d04fdbae494bcf4839c4ec5e6ec1d0bf600;hp=1e981d3c2f473d8aece89b86ba052bf43046dd07;hpb=4a83f322cdf4374c7e4bce4c7f32ad07203d55b8;p=haskell-directory.git diff --git a/cbits/dirUtils.c b/cbits/dirUtils.c index 1e981d3..d6da255 100644 --- a/cbits/dirUtils.c +++ b/cbits/dirUtils.c @@ -4,6 +4,7 @@ * Directory Runtime Support */ +/* needed only for solaris2_HOST_OS */ #include "ghcconfig.h" // The following is required on Solaris to force the POSIX versions of @@ -14,7 +15,7 @@ #include "HsBase.h" -#if defined(mingw32_HOST_OS) || defined(__MINGW32__) || defined(_MSC_VER) +#if defined(_MSC_VER) || defined(__MINGW32__) || defined(_WIN32) #include static @@ -56,16 +57,15 @@ toErrno(DWORD rc) * read an entry from the directory stream; opt for the * re-entrant friendly way of doing this, if available. */ -HsInt -__hscore_readdir( HsAddr dirPtr, HsAddr pDirEnt ) +int +__hscore_readdir( DIR *dirPtr, struct dirent **pDirEnt ) { - struct dirent **pDirE = (struct dirent**)pDirEnt; #if HAVE_READDIR_R struct dirent* p; int res; static unsigned int nm_max = (unsigned int)-1; - if (pDirE == NULL) { + if (pDirEnt == NULL) { return -1; } if (nm_max == (unsigned int)-1) { @@ -79,24 +79,24 @@ __hscore_readdir( HsAddr dirPtr, HsAddr pDirEnt ) } p = (struct dirent*)malloc(sizeof(struct dirent) + nm_max); if (p == NULL) return -1; - res = readdir_r((DIR*)dirPtr, p, pDirE); + res = readdir_r(dirPtr, p, pDirEnt); if (res != 0) { - *pDirE = NULL; + *pDirEnt = NULL; free(p); } - else if (*pDirE == NULL) { + else if (*pDirEnt == NULL) { // end of stream free(p); } return res; #else - if (pDirE == NULL) { + if (pDirEnt == NULL) { return -1; } - *pDirE = readdir((DIR*)dirPtr); - if (*pDirE == NULL) { + *pDirEnt = readdir(dirPtr); + if (*pDirEnt == NULL) { return -1; } else { return 0; @@ -113,11 +113,10 @@ __hscore_readdir( HsAddr dirPtr, HsAddr pDirEnt ) * an error * */ -HsInt -__hscore_renameFile( HsAddr src, - HsAddr dest) +int +__hscore_renameFile( char *src, char *dest) { -#if defined(mingw32_HOST_OS) || defined(__MINGW32__) || defined(_MSC_VER) +#if defined(_MSC_VER) || defined(__MINGW32__) || defined(_WIN32) static int forNT = -1; /* ToDo: propagate error codes back */ @@ -179,7 +178,7 @@ __hscore_renameFile( HsAddr src, * that have shell32's lacking that particular API. * */ -#if defined(mingw32_HOST_OS) || defined(__MINGW32__) || defined(_MSC_VER) +#if defined(_MSC_VER) || defined(__MINGW32__) || defined(_WIN32) typedef HRESULT (*HSCORE_GETAPPFOLDERFUNTY)(HWND,int,HANDLE,DWORD,char*); int __hscore_getFolderPath(HWND hwndOwner,