diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2024-03-19 19:47:48 +0800 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2024-03-19 19:47:48 +0800 |
commit | 4b47032686c52de5bf2324c1b1d4151c5fd6c41b (patch) | |
tree | 85098e25c0a4ad383f267fd59d591346d5e09a17 /Utility/FileSize.hs | |
parent | 34f99f9355c275917ff91539bbdac60a56ad7e17 (diff) | |
parent | 4993eab4a4507d52037ff74c67f6ca04d2401b5e (diff) | |
download | git-repair-4b47032686c52de5bf2324c1b1d4151c5fd6c41b.tar.gz |
Merge tag '1.20230814'
tagging package git-repair version 1.20230814
Diffstat (limited to 'Utility/FileSize.hs')
-rw-r--r-- | Utility/FileSize.hs | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/Utility/FileSize.hs b/Utility/FileSize.hs index 8544ad4..3d216f2 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,11 +14,15 @@ module Utility.FileSize ( getFileSize', ) where -import System.PosixCompat.Files #ifdef mingw32_HOST_OS import Control.Exception (bracket) import System.IO +import Utility.FileSystemEncoding +#else +import System.PosixCompat.Files (fileSize) #endif +import System.PosixCompat.Files (FileStatus) +import qualified Utility.RawFilePath as R type FileSize = Integer @@ -26,18 +32,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 |