2016-02-15 15:29:27 +00:00
|
|
|
{- disk free space checking shim
|
2012-03-22 21:09:54 +00:00
|
|
|
-
|
2016-02-15 15:29:27 +00:00
|
|
|
- Copyright 2016 Joey Hess <id@joeyh.name>
|
2012-03-22 21:09:54 +00:00
|
|
|
-
|
2014-05-10 14:01:27 +00:00
|
|
|
- License: BSD-2-clause
|
2012-03-22 21:09:54 +00:00
|
|
|
-}
|
|
|
|
|
2016-02-15 15:29:27 +00:00
|
|
|
{-# OPTIONS_GHC -fno-warn-tabs #-}
|
2016-03-08 06:45:10 +00:00
|
|
|
{-# LANGUAGE CPP #-}
|
2012-03-22 21:09:54 +00:00
|
|
|
|
2014-01-23 02:19:52 +00:00
|
|
|
module Utility.DiskFree (
|
|
|
|
getDiskFree,
|
|
|
|
getDiskSize
|
|
|
|
) where
|
2012-03-22 21:09:54 +00:00
|
|
|
|
2016-03-08 06:45:10 +00:00
|
|
|
#ifndef __ANDROID__
|
|
|
|
|
2016-02-15 15:29:27 +00:00
|
|
|
import System.DiskSpace
|
|
|
|
import Utility.Applicative
|
|
|
|
import Utility.Exception
|
2013-12-10 05:18:04 +00:00
|
|
|
|
|
|
|
getDiskFree :: FilePath -> IO (Maybe Integer)
|
2016-02-15 15:29:27 +00:00
|
|
|
getDiskFree = catchMaybeIO . getAvailSpace
|
2014-01-23 02:19:52 +00:00
|
|
|
|
|
|
|
getDiskSize :: FilePath -> IO (Maybe Integer)
|
2016-02-15 15:29:27 +00:00
|
|
|
getDiskSize = fmap diskTotal <$$> catchMaybeIO . getDiskUsage
|
2016-03-08 06:45:10 +00:00
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
#warning Building without disk free space checking support
|
|
|
|
|
|
|
|
getDiskFree :: FilePath -> IO (Maybe Integer)
|
|
|
|
getDiskFree _ = return Nothing
|
|
|
|
|
|
|
|
getDiskSize :: FilePath -> IO (Maybe Integer)
|
|
|
|
getDiskSize _ = return Nothing
|
|
|
|
|
|
|
|
#endif
|