mirror of
https://github.com/minio/minio.git
synced 2024-12-27 15:45:55 -05:00
497f13d733
- limit list buckets to limit only 100 buckets, all uppercase buckets are now lowercase and work transparently with all calls. - Change disk.Stat to disk.GetInfo and return back disk.Info{} struct. - Introduce new ioutils package which implements ReadDirN(path, n), ReadDirNamesN(path, n)
59 lines
2.2 KiB
Go
59 lines
2.2 KiB
Go
// +build windows
|
|
|
|
/*
|
|
* Minio Cloud Storage, (C) 2015 Minio, Inc.
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
package disk
|
|
|
|
import (
|
|
"syscall"
|
|
"unsafe"
|
|
)
|
|
|
|
// GetInfo returns total and free bytes available in a directory, e.g. `C:\`.
|
|
// It returns free space available to the user (including quota limitations)
|
|
//
|
|
// https://msdn.microsoft.com/en-us/library/windows/desktop/aa364937(v=vs.85).aspx
|
|
func GetInfo(path string) (info Info, err error) {
|
|
dll := syscall.MustLoadDLL("kernel32.dll")
|
|
// https://msdn.microsoft.com/en-us/library/windows/desktop/aa364937(v=vs.85).aspx
|
|
// Retrieves information about the amount of space that is available on a disk volume,
|
|
// which is the total amount of space, the total amount of free space, and the total
|
|
// amount of free space available to the user that is associated with the calling thread.
|
|
GetDiskFreeSpaceEx := dll.MustFindProc("GetDiskFreeSpaceExW")
|
|
|
|
lpFreeBytesAvailable := int64(0)
|
|
lpTotalNumberOfBytes := int64(0)
|
|
lpTotalNumberOfFreeBytes := int64(0)
|
|
|
|
// Extract values safely
|
|
// BOOL WINAPI GetDiskFreeSpaceEx(
|
|
// _In_opt_ LPCTSTR lpDirectoryName,
|
|
// _Out_opt_ PULARGE_INTEGER lpFreeBytesAvailable,
|
|
// _Out_opt_ PULARGE_INTEGER lpTotalNumberOfBytes,
|
|
// _Out_opt_ PULARGE_INTEGER lpTotalNumberOfFreeBytes
|
|
// );
|
|
_, _, _ = GetDiskFreeSpaceEx.Call(uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(path))),
|
|
uintptr(unsafe.Pointer(&lpFreeBytesAvailable)),
|
|
uintptr(unsafe.Pointer(&lpTotalNumberOfBytes)),
|
|
uintptr(unsafe.Pointer(&lpTotalNumberOfFreeBytes)))
|
|
info = Info{}
|
|
info.Total = int64(lpTotalNumberOfBytes)
|
|
info.Free = int64(lpFreeBytesAvailable)
|
|
info.FSType = getFSType(path)
|
|
return info, nil
|
|
}
|