2014-01-29 19:19:03 +00:00
|
|
|
{- POSIX files (and compatablity wrappers).
|
|
|
|
-
|
|
|
|
- This is like System.PosixCompat.Files, except with a fixed rename.
|
|
|
|
-
|
|
|
|
- Copyright 2014 Joey Hess <joey@kitenet.net>
|
|
|
|
-
|
|
|
|
- Licensed under the GNU GPL version 3 or higher.
|
|
|
|
-}
|
|
|
|
|
|
|
|
{-# LANGUAGE CPP #-}
|
|
|
|
|
|
|
|
module Utility.PosixFiles (
|
|
|
|
module X,
|
|
|
|
rename
|
|
|
|
) where
|
|
|
|
|
|
|
|
import System.PosixCompat.Files as X hiding (rename)
|
|
|
|
|
|
|
|
#ifndef mingw32_HOST_OS
|
|
|
|
import System.Posix.Files (rename)
|
|
|
|
#else
|
2014-01-29 21:19:46 +00:00
|
|
|
import qualified System.Win32.File as Win32
|
2014-01-29 19:19:03 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
{- System.PosixCompat.Files.rename on Windows calls renameFile,
|
2014-01-29 21:19:46 +00:00
|
|
|
- so cannot rename directories.
|
|
|
|
-
|
|
|
|
- Instead, use Win32 moveFile, which can. It needs to be told to overwrite
|
|
|
|
- any existing file. -}
|
2014-01-29 19:19:03 +00:00
|
|
|
#ifdef mingw32_HOST_OS
|
|
|
|
rename :: FilePath -> FilePath -> IO ()
|
2014-01-29 21:19:46 +00:00
|
|
|
rename src dest = Win32.moveFileEx src dest Win32.mOVEFILE_REPLACE_EXISTING
|
2014-01-29 19:19:03 +00:00
|
|
|
#endif
|