~axwalk/juju-core/lp1303195-manual-ubuntuuser-bash

« back to all changes in this revision

Viewing changes to utils/zfile_windows.go

  • Committer: Nate Finch
  • Date: 2013-10-10 19:49:54 UTC
  • mto: (1954.27.1 1.16)
  • mto: This revision was merged to the branch mainline in revision 1995.
  • Revision ID: nate.finch@canonical.com-20131010194954-yiqi32oe3y97u4d8
Create a cross-platform helper function to atomically replace a given file, since os.Rename won't work for that on Windows.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// mksyscall_windows.pl -l32 file_windows.go
 
2
// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
 
3
 
 
4
package utils
 
5
 
 
6
import "unsafe"
 
7
import "syscall"
 
8
 
 
9
var (
 
10
        modkernel32 = syscall.NewLazyDLL("kernel32.dll")
 
11
 
 
12
        procMoveFileExW = modkernel32.NewProc("MoveFileExW")
 
13
)
 
14
 
 
15
func moveFileEx(lpExistingFileName *uint16, lpNewFileName *uint16, dwFlags uint32) (err error) {
 
16
        r1, _, e1 := syscall.Syscall(procMoveFileExW.Addr(), 3, uintptr(unsafe.Pointer(lpExistingFileName)), uintptr(unsafe.Pointer(lpNewFileName)), uintptr(dwFlags))
 
17
        if r1 == 0 {
 
18
                if e1 != 0 {
 
19
                        err = error(e1)
 
20
                } else {
 
21
                        err = syscall.EINVAL
 
22
                }
 
23
        }
 
24
        return
 
25
}