summaryrefslogtreecommitdiff
path: root/Utility/FileSize.hs
diff options
context:
space:
mode:
authorJoey Hess <joeyh@joeyh.name>2021-01-11 21:52:32 -0400
committerJoey Hess <joeyh@joeyh.name>2021-01-11 21:52:32 -0400
commitad48349741384ed0e49fab9cf13ac7f90aba0dd1 (patch)
tree6b8c894ce1057d069f89e7209c266f00ea43ec66 /Utility/FileSize.hs
parentb3e72e94efbce652f25fb99d6c6ace8beb2a52d4 (diff)
downloadgit-repair-ad48349741384ed0e49fab9cf13ac7f90aba0dd1.tar.gz
Merge from git-annex.
Diffstat (limited to 'Utility/FileSize.hs')
-rw-r--r--Utility/FileSize.hs14
1 files changed, 9 insertions, 5 deletions
diff --git a/Utility/FileSize.hs b/Utility/FileSize.hs
index 8544ad4..a503fda 100644
--- a/Utility/FileSize.hs
+++ b/Utility/FileSize.hs
@@ -1,5 +1,7 @@
{- File size.
-
+ - Copyright 2015-2020 Joey Hess <id@joeyh.name>
+ -
- License: BSD-2-clause
-}
@@ -12,10 +14,12 @@ module Utility.FileSize (
getFileSize',
) where
-import System.PosixCompat.Files
+import System.PosixCompat.Files hiding (removeLink)
+import qualified Utility.RawFilePath as R
#ifdef mingw32_HOST_OS
import Control.Exception (bracket)
import System.IO
+import Utility.FileSystemEncoding
#endif
type FileSize = Integer
@@ -26,18 +30,18 @@ type FileSize = Integer
- FileOffset which maxes out at 2 gb.
- See https://github.com/jystic/unix-compat/issues/16
-}
-getFileSize :: FilePath -> IO FileSize
+getFileSize :: R.RawFilePath -> IO FileSize
#ifndef mingw32_HOST_OS
-getFileSize f = fmap (fromIntegral . fileSize) (getFileStatus f)
+getFileSize f = fmap (fromIntegral . fileSize) (R.getFileStatus f)
#else
-getFileSize f = bracket (openFile f ReadMode) hClose hFileSize
+getFileSize f = bracket (openFile (fromRawFilePath f) ReadMode) hClose hFileSize
#endif
{- Gets the size of the file, when its FileStatus is already known.
-
- On windows, uses getFileSize. Otherwise, the FileStatus contains the
- size, so this does not do any work. -}
-getFileSize' :: FilePath -> FileStatus -> IO FileSize
+getFileSize' :: R.RawFilePath -> FileStatus -> IO FileSize
#ifndef mingw32_HOST_OS
getFileSize' _ s = return $ fromIntegral $ fileSize s
#else