本文整理匯總了Golang中syscall.FullPath函數的典型用法代碼示例。如果您正苦於以下問題:Golang FullPath函數的具體用法?Golang FullPath怎麽用?Golang FullPath使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了FullPath函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: abs
func abs(path string) (string, error) {
fullPath, err := syscall.FullPath(path)
if err != nil {
return "", err
}
return Clean(fullPath), nil
}
示例2: Lstat
// Lstat returns the FileInfo structure describing the named file.
// If the file is a symbolic link, the returned FileInfo
// describes the symbolic link. Lstat makes no attempt to follow the link.
// If there is an error, it will be of type *PathError.
func Lstat(name string) (FileInfo, error) {
if len(name) == 0 {
return nil, &PathError{"Lstat", name, syscall.Errno(syscall.ERROR_PATH_NOT_FOUND)}
}
if name == DevNull {
return &devNullStat, nil
}
fs := &fileStat{name: basename(name)}
namep, e := syscall.UTF16PtrFromString(name)
if e != nil {
return nil, &PathError{"Lstat", name, e}
}
e = syscall.GetFileAttributesEx(namep, syscall.GetFileExInfoStandard, (*byte)(unsafe.Pointer(&fs.sys)))
if e != nil {
return nil, &PathError{"GetFileAttributesEx", name, e}
}
fs.path = name
if !isAbs(fs.path) {
fs.path, e = syscall.FullPath(fs.path)
if e != nil {
return nil, e
}
}
return fs, nil
}
示例3: normalizePath
func normalizePath(path string) (string, error) {
var err error
if filepath.VolumeName(path) == "" && filepath.HasPrefix(path, "\\") {
path, err = syscall.FullPath(path)
if err != nil {
return "", iodine.New(err, nil)
}
}
return path, nil
}
示例4: normalizePath
func normalizePath(path string) string {
if filepath.VolumeName(path) == "" && filepath.HasPrefix(path, "\\") {
var err error
path, err = syscall.FullPath(path)
if err != nil {
panic(err)
}
}
return path
}
示例5: normalizeDir
func normalizeDir(dir string) (name string, err error) {
ndir, err := syscall.FullPath(dir)
if err != nil {
return "", err
}
if len(ndir) > 2 && isSlash(ndir[0]) && isSlash(ndir[1]) {
// dir cannot have \\server\share\path form
return "", syscall.EINVAL
}
return ndir, nil
}
示例6: joinExeDirAndFName
func joinExeDirAndFName(dir, p string) (name string, err error) {
if len(p) == 0 {
return "", syscall.EINVAL
}
if len(p) > 2 && isSlash(p[0]) && isSlash(p[1]) {
// \\server\share\path form
return p, nil
}
if len(p) > 1 && p[1] == ':' {
// has drive letter
if len(p) == 2 {
return "", syscall.EINVAL
}
if isSlash(p[2]) {
return p, nil
} else {
d, err := normalizeDir(dir)
if err != nil {
return "", err
}
if volToUpper(int(p[0])) == volToUpper(int(d[0])) {
return syscall.FullPath(d + "\\" + p[2:])
} else {
return syscall.FullPath(p)
}
}
} else {
// no drive letter
d, err := normalizeDir(dir)
if err != nil {
return "", err
}
if isSlash(p[0]) {
return syscall.FullPath(d[:2] + p)
} else {
return syscall.FullPath(d + "\\" + p)
}
}
// we shouldn't be here
// return "", syscall.EINVAL
}
示例7: openDir
func openDir(name string) (file *File, err error) {
var mask string
path := fixLongPath(name)
if len(path) == 2 && path[1] == ':' || (len(path) > 0 && path[len(path)-1] == '\\') { // it is a drive letter, like C:
mask = path + `*`
} else {
mask = path + `\*`
}
maskp, e := syscall.UTF16PtrFromString(mask)
if e != nil {
return nil, e
}
d := new(dirInfo)
r, e := syscall.FindFirstFile(maskp, &d.data)
if e != nil {
// FindFirstFile returns ERROR_FILE_NOT_FOUND when
// no matching files can be found. Then, if directory
// exists, we should proceed.
if e != syscall.ERROR_FILE_NOT_FOUND {
return nil, e
}
var fa syscall.Win32FileAttributeData
pathp, e := syscall.UTF16PtrFromString(path)
if e != nil {
return nil, e
}
e = syscall.GetFileAttributesEx(pathp, syscall.GetFileExInfoStandard, (*byte)(unsafe.Pointer(&fa)))
if e != nil {
return nil, e
}
if fa.FileAttributes&syscall.FILE_ATTRIBUTE_DIRECTORY == 0 {
return nil, e
}
d.isempty = true
}
d.path = path
if !isAbs(d.path) {
d.path, e = syscall.FullPath(d.path)
if e != nil {
return nil, e
}
}
f := newFile(r, name)
f.dirinfo = d
return f, nil
}
示例8: Lstat
// Lstat returns the FileInfo structure describing the named file.
// If the file is a symbolic link, the returned FileInfo
// describes the symbolic link. Lstat makes no attempt to follow the link.
// If there is an error, it will be of type *PathError.
func Lstat(name string) (FileInfo, error) {
if len(name) == 0 {
return nil, &PathError{"Lstat", name, syscall.Errno(syscall.ERROR_PATH_NOT_FOUND)}
}
if name == DevNull {
return &devNullStat, nil
}
fs := &fileStat{name: basename(name)}
namep, e := syscall.UTF16PtrFromString(fixLongPath(name))
if e != nil {
return nil, &PathError{"Lstat", name, e}
}
e = syscall.GetFileAttributesEx(namep, syscall.GetFileExInfoStandard, (*byte)(unsafe.Pointer(&fs.sys)))
if e != nil {
if e != windows.ERROR_SHARING_VIOLATION {
return nil, &PathError{"GetFileAttributesEx", name, e}
}
// try FindFirstFile now that GetFileAttributesEx failed
var fd syscall.Win32finddata
h, e2 := syscall.FindFirstFile(namep, &fd)
if e2 != nil {
return nil, &PathError{"FindFirstFile", name, e}
}
syscall.FindClose(h)
fs.sys.FileAttributes = fd.FileAttributes
fs.sys.CreationTime = fd.CreationTime
fs.sys.LastAccessTime = fd.LastAccessTime
fs.sys.LastWriteTime = fd.LastWriteTime
fs.sys.FileSizeHigh = fd.FileSizeHigh
fs.sys.FileSizeLow = fd.FileSizeLow
}
fs.path = name
if !isAbs(fs.path) {
fs.path, e = syscall.FullPath(fs.path)
if e != nil {
return nil, e
}
}
return fs, nil
}
示例9: openDir
func openDir(name string) (file *File, err error) {
maskp, e := syscall.UTF16PtrFromString(name + `\*`)
if e != nil {
return nil, e
}
d := new(dirInfo)
r, e := syscall.FindFirstFile(maskp, &d.data)
if e != nil {
// FindFirstFile returns ERROR_FILE_NOT_FOUND when
// no matching files can be found. Then, if directory
// exists, we should proceed.
if e != syscall.ERROR_FILE_NOT_FOUND {
return nil, e
}
var fa syscall.Win32FileAttributeData
namep, e := syscall.UTF16PtrFromString(name)
if e != nil {
return nil, e
}
e = syscall.GetFileAttributesEx(namep, syscall.GetFileExInfoStandard, (*byte)(unsafe.Pointer(&fa)))
if e != nil {
return nil, e
}
if fa.FileAttributes&syscall.FILE_ATTRIBUTE_DIRECTORY == 0 {
return nil, e
}
d.isempty = true
}
d.path = name
if !isAbs(d.path) {
d.path, e = syscall.FullPath(d.path)
if e != nil {
return nil, e
}
}
f := newFile(r, name)
f.dirinfo = d
return f, nil
}
示例10: abs
func abs(path string) (string, error) {
return syscall.FullPath(path)
}