aboutsummaryrefslogtreecommitdiff
path: root/Utility/DiskFree.hs
blob: be4e82355886977ca629b4231b685eaab9947158 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
{- disk free space checking shim
 -
 - Copyright 2016 Joey Hess <id@joeyh.name>
 -
 - License: BSD-2-clause
 -}

{-# OPTIONS_GHC -fno-warn-tabs #-}
{-# LANGUAGE CPP #-}

module Utility.DiskFree (
	getDiskFree,
	getDiskSize
) where

#ifndef __ANDROID__

import System.DiskSpace
import Utility.Applicative
import Utility.Exception

getDiskFree :: FilePath -> IO (Maybe Integer)
getDiskFree = catchMaybeIO . getAvailSpace

getDiskSize :: FilePath -> IO (Maybe Integer)
getDiskSize = fmap diskTotal <$$> catchMaybeIO . getDiskUsage

#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