file-io 0.1.6 → 0.2.0
raw patch · 5 files changed
+17/−11 lines, 5 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- System.File.OsPath.Internal: openTempFile' :: String -> OsPath -> OsString -> Bool -> CMode -> IO (OsPath, Handle)
+ System.File.OsPath.Internal: openTempFile' :: String -> OsPath -> OsString -> Bool -> CMode -> Bool -> IO (OsPath, Handle)
Files
- CHANGELOG.md +4/−0
- System/File/OsPath/Internal.hs +7/−7
- file-io.cabal +1/−1
- posix/System/File/Platform.hs +3/−2
- windows/System/File/Platform.hsc +2/−1
CHANGELOG.md view
@@ -1,5 +1,9 @@ # Revision history for file-io +## 0.2.0 -- 2025-01-30++* Add ability to use `cloexec` in `openTempFile'` wrt [#44](https://github.com/haskell/file-io/issues/44)+ ## 0.1.6 -- 2025-01-30 * Fix long path support on windows wrt [#39](https://github.com/haskell/file-io/issues/39)
System/File/OsPath/Internal.hs view
@@ -160,14 +160,14 @@ -- be truncated to 3 chars, e.g. \"foobar.ext\" will be -- \"fooXXX.ext\". -> IO (OsPath, Handle)-openTempFile tmp_dir template = openTempFile' "openTempFile" tmp_dir template False 0o600+openTempFile tmp_dir template = openTempFile' "openTempFile" tmp_dir template False 0o600 False -- | Like 'openTempFile', but opens the file in binary mode. See 'openBinaryFile' for more comments. -- -- @since 0.1.3 openBinaryTempFile :: OsPath -> OsString -> IO (OsPath, Handle) openBinaryTempFile tmp_dir template- = openTempFile' "openBinaryTempFile" tmp_dir template True 0o600+ = openTempFile' "openBinaryTempFile" tmp_dir template True 0o600 False -- | Like 'openTempFile', but uses the default file permissions --@@ -175,7 +175,7 @@ openTempFileWithDefaultPermissions :: OsPath -> OsString -> IO (OsPath, Handle) openTempFileWithDefaultPermissions tmp_dir template- = openTempFile' "openTempFileWithDefaultPermissions" tmp_dir template False 0o666+ = openTempFile' "openTempFileWithDefaultPermissions" tmp_dir template False 0o666 False -- | Like 'openBinaryTempFile', but uses the default file permissions --@@ -183,7 +183,7 @@ openBinaryTempFileWithDefaultPermissions :: OsPath -> OsString -> IO (OsPath, Handle) openBinaryTempFileWithDefaultPermissions tmp_dir template- = openTempFile' "openBinaryTempFileWithDefaultPermissions" tmp_dir template True 0o666+ = openTempFile' "openBinaryTempFileWithDefaultPermissions" tmp_dir template True 0o666 False -- --------------------------------------------------------------------------- -- Internals@@ -232,13 +232,13 @@ augmentError str osfp = flip catchException (ioError . addFilePathToIOError str osfp) -openTempFile' :: String -> OsPath -> OsString -> Bool -> CMode+openTempFile' :: String -> OsPath -> OsString -> Bool -> CMode -> Bool -> IO (OsPath, Handle)-openTempFile' loc (OsString tmp_dir) template@(OsString tmpl) binary mode+openTempFile' loc (OsString tmp_dir) template@(OsString tmpl) binary mode cloExec | any_ (== OSP.pathSeparator) template = throwIO $ userError $ "openTempFile': Template string must not contain path separator characters: " ++ P.lenientDecode tmpl | otherwise = do- (fp, hdl) <- P.findTempName (prefix, suffix) loc tmp_dir mode+ (fp, hdl) <- P.findTempName (prefix, suffix) loc tmp_dir mode cloExec when binary $ hSetBinaryMode hdl True pure (OsString fp, hdl) where
file-io.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.4 name: file-io-version: 0.1.6+version: 0.2.0 synopsis: Basic file IO operations via 'OsPath' description: Basic file IO operations like Prelude, but for 'OsPath'. homepage: https://github.com/hasufell/file-io
posix/System/File/Platform.hs view
@@ -84,8 +84,9 @@ -> String -> PosixPath -> CMode+ -> Bool -> IO (PosixPath, Handle)-findTempName (prefix, suffix) loc tmp_dir mode = go+findTempName (prefix, suffix) loc tmp_dir mode cloExec = go where go = do rs <- rand_string@@ -103,7 +104,7 @@ else fmap (filepath,) $ fdToHandle_ ReadWriteMode filepath fd openTempFile_ :: PosixPath -> CMode -> IO Fd- openTempFile_ fp cmode = openFd fp ReadWrite defaultFileFlags' { creat = Just cmode, nonBlock = True, noctty = True, exclusive = True }+ openTempFile_ fp cmode = openFd fp ReadWrite defaultFileFlags' { creat = Just cmode, nonBlock = True, noctty = True, exclusive = True, cloexec = cloExec } tempCounter :: IORef Int tempCounter = unsafePerformIO $ newIORef 0
windows/System/File/Platform.hsc view
@@ -174,8 +174,9 @@ -> String -> WindowsPath -> CMode+ -> Bool -> IO (WindowsPath, Handle)-findTempName (prefix, suffix) loc tmp_dir mode = go+findTempName (prefix, suffix) loc tmp_dir mode _cloExec = go where go = do let label = if prefix == mempty then fromJust (encodeUtf "ghc") else prefix