diff options
author | Joey Hess <joey@kitenet.net> | 2014-01-29 15:19:03 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2014-01-29 15:19:03 -0400 |
commit | 2f4061cce0eb1189d194cef6ef2e446da53cd854 (patch) | |
tree | f13a6b7066184d710e32f149b83e5bebc6b3e214 /Utility | |
parent | 322f68bda7305803b18598f9123a17377c8421ff (diff) |
Windows: Avoid using unix-compat's rename, which refuses to rename directories.
Opened a bug about this: https://github.com/jystic/unix-compat/issues/10
Diffstat (limited to 'Utility')
-rw-r--r-- | Utility/DirWatcher/Win32Notify.hs | 2 | ||||
-rw-r--r-- | Utility/Directory.hs | 2 | ||||
-rw-r--r-- | Utility/PosixFiles.hs | 30 |
3 files changed, 32 insertions, 2 deletions
diff --git a/Utility/DirWatcher/Win32Notify.hs b/Utility/DirWatcher/Win32Notify.hs index 27175e1c8..ba786839c 100644 --- a/Utility/DirWatcher/Win32Notify.hs +++ b/Utility/DirWatcher/Win32Notify.hs @@ -11,7 +11,7 @@ import Common hiding (isDirectory) import Utility.DirWatcher.Types import System.Win32.Notify -import qualified System.PosixCompat.Files as Files +import qualified Utility.PosixFiles as Files watchDir :: FilePath -> (FilePath -> Bool) -> WatchHooks -> IO WatchManager watchDir dir ignored hooks = do diff --git a/Utility/Directory.hs b/Utility/Directory.hs index 6caee7efa..c457de6e3 100644 --- a/Utility/Directory.hs +++ b/Utility/Directory.hs @@ -10,7 +10,6 @@ module Utility.Directory where import System.IO.Error -import System.PosixCompat.Files import System.Directory import Control.Exception (throw) import Control.Monad @@ -19,6 +18,7 @@ import System.FilePath import Control.Applicative import System.IO.Unsafe (unsafeInterleaveIO) +import Utility.PosixFiles import Utility.SafeCommand import Utility.Tmp import Utility.Exception diff --git a/Utility/PosixFiles.hs b/Utility/PosixFiles.hs new file mode 100644 index 000000000..2c1a05a6a --- /dev/null +++ b/Utility/PosixFiles.hs @@ -0,0 +1,30 @@ +{- 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 +import System.Win32.File (moveFile) +#endif + +{- System.PosixCompat.Files.rename on Windows calls renameFile, + - so cannot rename directories. Instead, use Win32 moveFile, which can. -} +#ifdef mingw32_HOST_OS +rename :: FilePath -> FilePath -> IO () +rename = moveFile +#endif |