Skip to content

Commit

Permalink
Use openBinaryTempFile from file-io
Browse files Browse the repository at this point in the history
  • Loading branch information
hasufell committed Aug 10, 2024
1 parent 6045b93 commit ab4650e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
12 changes: 5 additions & 7 deletions System/Directory/OsPath.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{-# LANGUAGE QuasiQuotes #-}

-----------------------------------------------------------------------------
-- |
-- Module : System.Directory.OsPath
Expand Down Expand Up @@ -105,6 +107,8 @@ module System.Directory.OsPath
import Prelude ()
import System.Directory.Internal
import System.Directory.Internal.Prelude
import System.OsString (osstr)
import qualified System.File.OsPath as OS
import System.OsPath

Check failure on line 112 in System/Directory/OsPath.hs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 8.10.7, 3.8.1.0)

The import of ‘decodeFS, encodeFS’

Check failure on line 112 in System/Directory/OsPath.hs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 9.0.2, 3.8.1.0)

The import of ‘decodeFS, encodeFS’

Check failure on line 112 in System/Directory/OsPath.hs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 9.2.4, 3.8.1.0)

The import of ‘decodeFS, encodeFS’

Check failure on line 112 in System/Directory/OsPath.hs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 9.4.3, 3.8.1.0)

The import of ‘decodeFS, encodeFS’

Check failure on line 112 in System/Directory/OsPath.hs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, latest, latest, +os-string, -Werror=deprecations)

The import of ‘decodeFS, encodeFS’
( (<.>)
, (</>)
Expand Down Expand Up @@ -749,13 +753,7 @@ withReplacementFile :: OsPath -- ^ Destination file
withReplacementFile path postAction action =
(`ioeAddLocation` "withReplacementFile") `modifyIOError` do
mask $ \ restore -> do
-- TODO: AFPP doesn't support openBinaryTempFile yet,
-- so we have to use this (sad) workaround
-- (on unix, converts using filesystem encoding, on windows
-- converts with UTF-16LE)
d <- decodeFS (takeDirectory path)
(tmpFPath', hTmp) <- openBinaryTempFile d ".copyFile.tmp"
tmpFPath <- encodeFS tmpFPath'
(tmpFPath, hTmp) <- OS.openBinaryTempFile (takeDirectory path) [osstr|.copyFile.tmp|]
(`onException` ignoreIOExceptions (removeFile tmpFPath)) $ do
r <- (`onException` ignoreIOExceptions (hClose hTmp)) $ do
restore (action hTmp)
Expand Down
2 changes: 1 addition & 1 deletion directory.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Library

build-depends:
base >= 4.12.0 && < 4.21,
file-io >= 0.1.2 && < 0.2,
file-io >= 0.1.3 && < 0.2,
time >= 1.8.0 && < 1.15,
if os(windows)
build-depends: Win32 >= 2.13.3 && < 2.15
Expand Down

0 comments on commit ab4650e

Please sign in to comment.