diff options
-rw-r--r-- | erebos.cabal | 6 | ||||
-rw-r--r-- | src/windows/Erebos/Storage/Platform.hs | 13 |
2 files changed, 18 insertions, 1 deletions
diff --git a/erebos.cabal b/erebos.cabal index 472811f..d8730b9 100644 --- a/erebos.cabal +++ b/erebos.cabal @@ -161,7 +161,11 @@ library uuid >=1.3 && <1.4, zlib >=0.6 && <0.8 - if true + if os(windows) + hs-source-dirs: src/windows + build-depends: + Win32 ^>= { 2.14 }, + else hs-source-dirs: src/unix build-depends: unix ^>= { 2.7, 2.8 }, diff --git a/src/windows/Erebos/Storage/Platform.hs b/src/windows/Erebos/Storage/Platform.hs new file mode 100644 index 0000000..76c940b --- /dev/null +++ b/src/windows/Erebos/Storage/Platform.hs @@ -0,0 +1,13 @@ +module Erebos.Storage.Platform ( + createFileExclusive, +) where + +import Data.Bits + +import System.IO +import System.Win32.File +import System.Win32.Types + +createFileExclusive :: FilePath -> IO Handle +createFileExclusive path = do + hANDLEToHandle =<< createFile path gENERIC_WRITE (fILE_SHARE_READ .|. fILE_SHARE_DELETE) Nothing cREATE_NEW fILE_ATTRIBUTE_NORMAL Nothing |