File: PosixFiles.hs

package info (click to toggle)
git-annex 5.20141125+deb8u1
  • links: PTS
  • area: main
  • in suites: jessie
  • size: 37,832 kB
  • sloc: haskell: 42,603; sh: 1,080; ansic: 498; makefile: 316; perl: 125
file content (33 lines) | stat: -rw-r--r-- 797 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
{- POSIX files (and compatablity wrappers).
 -
 - This is like System.PosixCompat.Files, except with a fixed rename.
 -
 - Copyright 2014 Joey Hess <joey@kitenet.net>
 -
 - License: BSD-2-clause
 -}

{-# 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 qualified System.Win32.File as Win32
#endif

{- System.PosixCompat.Files.rename on Windows calls renameFile,
 - so cannot rename directories. 
 -
 - Instead, use Win32 moveFile, which can. It needs to be told to overwrite
 - any existing file. -}
#ifdef mingw32_HOST_OS
rename :: FilePath -> FilePath -> IO ()
rename src dest = Win32.moveFileEx src dest Win32.mOVEFILE_REPLACE_EXISTING
#endif