Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
MKCLOS
Core Development Platform
corepkgv2
Commits
67fad8d6
Commit
67fad8d6
authored
4 years ago
by
Kunal Taitkar
Browse files
Options
Downloads
Patches
Plain Diff
Build failed on mac os( filemdl_darwin.go had windows sys calls)
parent
d2647d21
2 merge requests
!180
Mep release 07042020
,
!179
Build failed on mac os( filemdl_darwin.go had windows sys calls)
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
filemdl/filemdl_darwin.go
+4
-40
filemdl/filemdl_darwin.go
with
4 additions
and
40 deletions
filemdl/filemdl_darwin.go
+
4
−
40
View file @
67fad8d6
// TODO: Build flag needs to be passed while building exe/executable
// +build !windows
package
filemdl
import
(
"os"
"syscall"
"unsafe"
)
const
(
moveFileReplacExisting
=
0x1
moveFileWriteThrough
=
0x8
)
var
(
modkernel32
=
syscall
.
NewLazyDLL
(
"kernel32.dll"
)
procMoveFileExW
=
modkernel32
.
NewProc
(
"MoveFileExW"
)
)
//sys moveFileEx(lpExistingFileName *uint16, lpNewFileName *uint16, dwFlags uint32) (err error) = MoveFileExW
// AtomicReplaceFile atomically replaces the destination file or directory with the
// source. It is guaranteed to either replace the target file entirely, or not
// change either file.
func
AtomicReplaceFile
(
source
,
destination
string
)
error
{
src
,
err
:=
syscall
.
UTF16PtrFromString
(
source
)
if
err
!=
nil
{
return
&
os
.
LinkError
{
"replace"
,
source
,
destination
,
err
}
}
dest
,
err
:=
syscall
.
UTF16PtrFromString
(
destination
)
if
err
!=
nil
{
return
&
os
.
LinkError
{
"replace"
,
source
,
destination
,
err
}
}
// see http://msdn.microsoft.com/en-us/library/windows/desktop/aa365240(v=vs.85).aspx
if
err
:=
moveFileEx
(
src
,
dest
,
moveFileReplacExisting
|
moveFileWriteThrough
);
err
!=
nil
{
return
&
os
.
LinkError
{
"replace"
,
source
,
destination
,
err
}
}
return
nil
}
func
moveFileEx
(
lpExistingFileName
*
uint16
,
lpNewFileName
*
uint16
,
dwFlags
uint32
)
(
err
error
)
{
r1
,
_
,
e1
:=
syscall
.
Syscall
(
procMoveFileExW
.
Addr
(),
3
,
uintptr
(
unsafe
.
Pointer
(
lpExistingFileName
)),
uintptr
(
unsafe
.
Pointer
(
lpNewFileName
)),
uintptr
(
dwFlags
))
if
r1
==
0
{
if
e1
!=
0
{
err
=
error
(
e1
)
}
else
{
err
=
syscall
.
EINVAL
}
}
return
return
os
.
Rename
(
source
,
destination
)
}
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets