windows disk free space checking

This commit is contained in:
Joey Hess 2013-12-10 01:18:04 -04:00
parent 8699a36438
commit 063a183a61
4 changed files with 22 additions and 12 deletions

View file

@ -31,8 +31,18 @@ getDiskFree path = withFilePath path $ \c_path -> do
safeErrno (Errno v) = v == 0
#else
#ifdef mingw32_HOST_OS
import System.Win32.File
getDiskFree :: FilePath -> IO (Maybe Integer)
getDiskFree path = catchMaybeIO $ do
(sectors, bytes, nfree, _ntotal) <- getDiskFreeSpace (Just path)
return $ toInteger sectors * toInteger bytes * toInteger nfree
#else
getDiskFree :: FilePath -> IO (Maybe Integer)
getDiskFree _ = return Nothing
#endif
#endif