use openTempFile from file-io
And follow-on changes. Note that relatedTemplate was changed to operate on a RawFilePath, and so when it counts the length, it is now the number of bytes, not the number of code points. This will just make it truncate shorter strings in some cases, the truncation is still unicode aware. When not building with the OsPath flag, toOsPath . fromRawFilePath and fromRawFilePath . fromOsPath do extra conversions back and forth between String and ByteString. That overhead could be avoided, but that's the non-optimised build mode, so didn't bother. Sponsored-by: unqueued
This commit is contained in:
parent
1faa3af9cd
commit
793ddecd4b
46 changed files with 235 additions and 178 deletions
|
@ -40,6 +40,7 @@ import Utility.Env
|
|||
import Utility.Env.Set
|
||||
import Utility.Tmp
|
||||
import Utility.RawFilePath
|
||||
import Utility.OsPath
|
||||
import qualified Utility.LockFile.Posix as Posix
|
||||
|
||||
import System.IO
|
||||
|
@ -149,9 +150,10 @@ tryLock lockfile = do
|
|||
_ -> return (Just ParentLocked)
|
||||
where
|
||||
go abslockfile sidelock = do
|
||||
let abslockfile' = fromRawFilePath abslockfile
|
||||
(tmp, h) <- openTmpFileIn (takeDirectory abslockfile') "locktmp"
|
||||
let tmp' = toRawFilePath tmp
|
||||
(tmp, h) <- openTmpFileIn
|
||||
(toOsPath (P.takeDirectory abslockfile))
|
||||
(toOsPath "locktmp")
|
||||
let tmp' = fromOsPath tmp
|
||||
setFileMode tmp' (combineModes readModes)
|
||||
hPutStr h . show =<< mkPidLock
|
||||
hClose h
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue