File tree 4 files changed +31
-2
lines changed 4 files changed +31
-2
lines changed Original file line number Diff line number Diff line change @@ -190,6 +190,7 @@ module System.Win32.File
190
190
, removeDirectory
191
191
, getBinaryType
192
192
, getTempFileName
193
+ , replaceFile
193
194
194
195
-- * HANDLE operations
195
196
, createFile
@@ -419,6 +420,10 @@ getFileInformationByHandle h = alloca $ \res -> do
419
420
failIfFalseWithRetry_ " GetFileInformationByHandle" $ c_GetFileInformationByHandle h res
420
421
peek res
421
422
423
+ replaceFile :: LPCWSTR -> LPCWSTR -> LPCWSTR -> DWORD -> IO ()
424
+ replaceFile replacedFile replacementFile backupFile replaceFlags =
425
+ failIfFalse_ " ReplaceFile" $ c_ReplaceFile replacedFile replacementFile backupFile replaceFlags nullPtr nullPtr
426
+
422
427
----------------------------------------------------------------
423
428
-- Read/write files
424
429
----------------------------------------------------------------
Original file line number Diff line number Diff line change @@ -193,6 +193,16 @@ type BinaryType = DWORD
193
193
194
194
----------------------------------------------------------------
195
195
196
+ type ReplaceType = DWORD
197
+
198
+ #{enum ReplaceType,
199
+ , rEPLACEFILE_WRITE_THROUGH = REPLACEFILE_WRITE_THROUGH
200
+ , rEPLACEFILE_IGNORE_MERGE_ERRORS = REPLACEFILE_IGNORE_MERGE_ERRORS
201
+ , rEPLACEFILE_IGNORE_ACL_ERRORS = REPLACEFILE_IGNORE_ACL_ERRORS
202
+ }
203
+
204
+ ----------------------------------------------------------------
205
+
196
206
type FileNotificationFlag = DWORD
197
207
198
208
#{enum FileNotificationFlag,
@@ -367,6 +377,9 @@ foreign import WINDOWS_CCONV unsafe "windows.h RemoveDirectoryW"
367
377
foreign import WINDOWS_CCONV unsafe " windows.h GetBinaryTypeW"
368
378
c_GetBinaryType :: LPCTSTR -> Ptr DWORD -> IO Bool
369
379
380
+ foreign import WINDOWS_CCONV unsafe " windows.h ReplaceFileW"
381
+ c_ReplaceFile :: LPCWSTR -> LPCWSTR -> LPCWSTR -> DWORD -> LPVOID -> LPVOID -> IO Bool
382
+
370
383
----------------------------------------------------------------
371
384
-- HANDLE operations
372
385
----------------------------------------------------------------
Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ module System.Win32.WindowsString.File
35
35
, setVolumeLabel
36
36
, getFileExInfoStandard
37
37
, getFileExMaxInfoLevel
38
+ , replaceFile
38
39
, module System.Win32.File
39
40
) where
40
41
@@ -62,6 +63,7 @@ import System.Win32.File hiding (
62
63
, setVolumeLabel
63
64
, getFileExInfoStandard
64
65
, getFileExMaxInfoLevel
66
+ , replaceFile
65
67
)
66
68
import System.Win32.WindowsString.Types
67
69
import System.OsString.Windows
@@ -180,7 +182,16 @@ getTempFileName dir prefix unique = allocaBytes ((#const MAX_PATH) * sizeOf (und
180
182
fname <- peekTString c_buf
181
183
pure (fname, uid)
182
184
183
-
185
+ replaceFile :: WindowsString -> WindowsString -> Maybe WindowsString -> DWORD -> IO ()
186
+ replaceFile replacedFile replacementFile mBackupFile replaceFlags =
187
+ withFilePath replacedFile $ \ c_replacedFile ->
188
+ withFilePath replacementFile $ \ c_replacementFile ->
189
+ let getResult f =
190
+ case mBackupFile of
191
+ Nothing -> f nullPtr
192
+ Just backupFile -> withFilePath backupFile f
193
+ in getResult $ \ c_backupFile ->
194
+ failIfFalse_ " ReplaceFile" $ c_ReplaceFile c_replacedFile c_replacementFile c_backupFile replaceFlags nullPtr nullPtr
184
195
185
196
----------------------------------------------------------------
186
197
-- File Notifications
Original file line number Diff line number Diff line change 1
1
cabal-version : 2.0
2
2
name : Win32
3
- version : 2.14.1 .0
3
+ version : 2.14.2 .0
4
4
license : BSD3
5
5
license-file : LICENSE
6
6
author : Alastair Reid, shelarcy, Tamar Christina
You can’t perform that action at this time.
0 commit comments