more OsPath conversion

Finally reached Annex code in this conversion.

Sponsored-by: Graham Spencer
This commit is contained in:
Joey Hess 2025-01-25 10:54:51 -04:00
parent 51a6cd1ee6
commit f9d42c37c0
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
9 changed files with 64 additions and 37 deletions

View file

@ -24,6 +24,7 @@ import System.PosixCompat.Files (fileSize)
#endif
import System.PosixCompat.Files (FileStatus)
import qualified Utility.RawFilePath as R
import Utility.OsPath
type FileSize = Integer
@ -33,18 +34,18 @@ type FileSize = Integer
- FileOffset which maxes out at 2 gb.
- See https://github.com/jystic/unix-compat/issues/16
-}
getFileSize :: R.RawFilePath -> IO FileSize
getFileSize :: OsPath -> IO FileSize
#ifndef mingw32_HOST_OS
getFileSize f = fmap (fromIntegral . fileSize) (R.getFileStatus f)
getFileSize f = fmap (fromIntegral . fileSize) (R.getFileStatus (fromOsPath f))
#else
getFileSize f = bracket (F.openFile (toOsPath f) ReadMode) hClose hFileSize
getFileSize f = bracket (F.openFile 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' :: R.RawFilePath -> FileStatus -> IO FileSize
getFileSize' :: OsPath -> FileStatus -> IO FileSize
#ifndef mingw32_HOST_OS
getFileSize' _ s = return $ fromIntegral $ fileSize s
#else