import Control.Monad.IfElse
import System.Posix.Files
import Control.Monad
-import qualified Data.ByteString.Lazy as L
import qualified Data.Map as M
import Utility.SafeCommand
import Utility.Directory
import Utility.Env
import Utility.SystemDirectory
+import qualified Utility.FileIO as F
import Build.BundledPrograms
#ifdef darwin_HOST_OS
import System.IO
let linktarget' = progDir topdir </> takeFileName linktarget
unlessM (doesFileExist linktarget') $ do
createDirectoryIfMissing True (takeDirectory linktarget')
- L.readFile f' >>= L.writeFile (fromOsPath linktarget')
+ F.readFile f >>= F.writeFile linktarget'
removeWhenExistsWith removeFile destf
rellinktarget <- relPathDirToFile
(takeDirectory destf)
storeLegacyChunked meterupdate chunksize alldests@(firstdest:_) b
| L.null b = do
-- always write at least one file, even for empty
- L.writeFile firstdest b
+ F.writeFile (toOsPath firstdest) b
return [firstdest]
| otherwise = storeLegacyChunked' meterupdate chunksize alldests (L.toChunks b) []
storeLegacyChunked' :: MeterUpdate -> ChunkSize -> [FilePath] -> [S.ByteString] -> [FilePath] -> IO [FilePath]
let go = \k sink -> do
liftIO $ void $ withStoredFiles (fromOsPath d) (legacyLocations locations) k $ \fs -> do
forM_ fs $
- F.appendFile' tmp <=< S.readFile
+ F.appendFile' tmp <=< F.readFile' . toOsPath
return True
b <- liftIO $ F.readFile tmp
liftIO $ removeWhenExistsWith removeFile tmp
fileStorer :: (Key -> OsPath -> MeterUpdate -> Annex ()) -> Storer
fileStorer a k (FileContent f) m = a k f m
fileStorer a k (ByteContent b) m = withTmp k $ \f -> do
- liftIO $ L.writeFile (fromOsPath f) b
+ liftIO $ F.writeFile f b
a k f m
-- A Storer that expects to be provided with a L.ByteString of
-{- File IO on OsPaths.
+{- This is a subset of the functions provided by file-io.
+ -
+ - When not building with file-io, this provides equvilant
+ - RawFilePath versions.
-
- Since Prelude exports many of these as well, this needs to be imported
- qualified.
import Prelude (return)
import qualified System.File.OsPath as O
import qualified Data.ByteString as B
-import qualified Data.ByteString.Lazy as L
import Control.Applicative
withFile :: OsPath -> IOMode -> (Handle -> IO r) -> IO r