tweak
This commit is contained in:
parent
d75771b0ab
commit
37061c019d
2 changed files with 4 additions and 4 deletions
|
@ -18,7 +18,7 @@ import Foreign.C.Error
|
||||||
foreign import ccall unsafe "libdiskfree.h diskfree" c_diskfree
|
foreign import ccall unsafe "libdiskfree.h diskfree" c_diskfree
|
||||||
:: CString -> IO CULLong
|
:: CString -> IO CULLong
|
||||||
|
|
||||||
getDiskFree :: String -> IO (Maybe Integer)
|
getDiskFree :: FilePath -> IO (Maybe Integer)
|
||||||
getDiskFree path = withFilePath path $ \c_path -> do
|
getDiskFree path = withFilePath path $ \c_path -> do
|
||||||
free <- c_diskfree c_path
|
free <- c_diskfree c_path
|
||||||
ifM (safeErrno <$> getErrno)
|
ifM (safeErrno <$> getErrno)
|
||||||
|
|
|
@ -58,10 +58,10 @@ unsigned long long int diskfree(const char *path) {
|
||||||
unsigned long long int available, blocksize;
|
unsigned long long int available, blocksize;
|
||||||
struct STATSTRUCT buf;
|
struct STATSTRUCT buf;
|
||||||
|
|
||||||
if (STATCALL(path, &buf) != 0) {
|
if (STATCALL(path, &buf) != 0)
|
||||||
return 0; /* errno is set */
|
return 0; /* errno is set */
|
||||||
}
|
else
|
||||||
errno = 0;
|
errno = 0;
|
||||||
|
|
||||||
available = buf.f_bavail;
|
available = buf.f_bavail;
|
||||||
blocksize = buf.f_bsize;
|
blocksize = buf.f_bsize;
|
||||||
|
|
Loading…
Reference in a new issue