Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: 06c8b6c89a
Fetching contributors…

Cannot retrieve contributors at this time

55 lines (40 sloc) 1.205 kB
// Copyright 2010 The Walk Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package walk
import "syscall"
import . "github.com/lxn/go-winapi"
func knownFolderPath(id CSIDL) (string, error) {
var buf [MAX_PATH]uint16
if !ShGetSpecialFolderPath(0, &buf[0], id, false) {
return "", newError("ShGetSpecialFolderPath failed")
}
return syscall.UTF16ToString(buf[0:]), nil
}
func AppDataPath() (string, error) {
return knownFolderPath(CSIDL_APPDATA)
}
func CommonAppDataPath() (string, error) {
return knownFolderPath(CSIDL_COMMON_APPDATA)
}
func LocalAppDataPath() (string, error) {
return knownFolderPath(CSIDL_LOCAL_APPDATA)
}
func DriveNames() ([]string, error) {
bufLen := GetLogicalDriveStrings(0, nil)
if bufLen == 0 {
return nil, lastError("GetLogicalDriveStrings")
}
buf := make([]uint16, bufLen+1)
bufLen = GetLogicalDriveStrings(bufLen+1, &buf[0])
if bufLen == 0 {
return nil, lastError("GetLogicalDriveStrings")
}
var names []string
for i := 0; i < len(buf)-2; {
name := syscall.UTF16ToString(buf[i:])
names = append(names, name)
i += len(name) + 1
}
return names, nil
}
Jump to Line
Something went wrong with that request. Please try again.