summaryrefslogtreecommitdiff
path: root/Utility/PosixFiles.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-01-29 15:19:03 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-01-29 15:19:03 -0400
commit2f4061cce0eb1189d194cef6ef2e446da53cd854 (patch)
treef13a6b7066184d710e32f149b83e5bebc6b3e214 /Utility/PosixFiles.hs
parent322f68bda7305803b18598f9123a17377c8421ff (diff)
Windows: Avoid using unix-compat's rename, which refuses to rename directories.
Diffstat (limited to 'Utility/PosixFiles.hs')
-rw-r--r--Utility/PosixFiles.hs30
1 files changed, 30 insertions, 0 deletions
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