github.com/pingcap/br@v5.3.0-alpha.0.20220125034240-ec59c7b6ce30+incompatible/pkg/lightning/common/storage_windows.go (about) 1 // Copyright 2019 PingCAP, Inc. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // See the License for the specific language governing permissions and 12 // limitations under the License. 13 14 // +build windows 15 16 // TODO: Deduplicate this implementation with DM! 17 18 package common 19 20 import ( 21 "syscall" 22 "unsafe" 23 24 "github.com/pingcap/errors" 25 ) 26 27 var ( 28 kernel32 = syscall.MustLoadDLL("kernel32.dll") 29 getDiskFreeSpaceExW = kernel32.MustFindProc("GetDiskFreeSpaceExW") 30 ) 31 32 // GetStorageSize gets storage's capacity and available size 33 func GetStorageSize(dir string) (size StorageSize, err error) { 34 r, _, e := getDiskFreeSpaceExW.Call( 35 uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(dir))), 36 uintptr(unsafe.Pointer(&size.Available)), 37 uintptr(unsafe.Pointer(&size.Capacity)), 38 0, 39 ) 40 if r == 0 { 41 err = errors.Annotatef(e, "cannot get disk capacity at %s", dir) 42 } 43 return 44 } 45 46 // SameDisk is used to check dir1 and dir2 in the same disk. 47 func SameDisk(dir1 string, dir2 string) (bool, error) { 48 // FIXME 49 return false, nil 50 }