mirror of
https://github.com/syncthing/syncthing.git
synced 2024-11-16 10:28:49 -07:00
40 lines
815 B
Go
40 lines
815 B
Go
// Copyright (C) 2014 Jakob Borg and Contributors (see the CONTRIBUTORS file).
|
|
// All rights reserved. Use of this source code is governed by an MIT-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
// +build windows
|
|
|
|
package osutil
|
|
|
|
import "syscall"
|
|
|
|
func HideFile(path string) error {
|
|
p, err := syscall.UTF16PtrFromString(path)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
attrs, err := syscall.GetFileAttributes(p)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
attrs |= syscall.FILE_ATTRIBUTE_HIDDEN
|
|
return syscall.SetFileAttributes(p, attrs)
|
|
}
|
|
|
|
func ShowFile(path string) error {
|
|
p, err := syscall.UTF16PtrFromString(path)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
attrs, err := syscall.GetFileAttributes(p)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
attrs &^= syscall.FILE_ATTRIBUTE_HIDDEN
|
|
return syscall.SetFileAttributes(p, attrs)
|
|
}
|