mirror of
https://github.com/golang/go
synced 2024-11-23 17:40:03 -07:00
os: add documentation for Windows users
Updates #18581 Updates #20858 Change-Id: I6b5ce0e255a42c028d46815fff5a5aca68690fd9 Reviewed-on: https://go-review.googlesource.com/47254 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
87c4a04b80
commit
92ad8df5d1
@ -292,3 +292,27 @@ func (f *File) wrapErr(op string, err error) error {
|
|||||||
func TempDir() string {
|
func TempDir() string {
|
||||||
return tempDir()
|
return tempDir()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Chmod changes the mode of the named file to mode.
|
||||||
|
// If the file is a symbolic link, it changes the mode of the link's target.
|
||||||
|
// If there is an error, it will be of type *PathError.
|
||||||
|
//
|
||||||
|
// A different subset of the mode bits are used, depending on the
|
||||||
|
// operating system.
|
||||||
|
//
|
||||||
|
// On Unix, the mode's permission bits, ModeSetuid, ModeSetgid, and
|
||||||
|
// ModeSticky are used.
|
||||||
|
//
|
||||||
|
// On Windows, the mode must be non-zero but otherwise only the 0200
|
||||||
|
// bit (owner writable) of mode is used; it controls whether the
|
||||||
|
// file's read-only attribute is set or cleared. attribute. The other
|
||||||
|
// bits are currently unused. Use mode 0400 for a read-only file and
|
||||||
|
// 0600 for a readable+writable file.
|
||||||
|
//
|
||||||
|
// On Plan 9, the mode's permission bits, ModeAppend, ModeExclusive,
|
||||||
|
// and ModeTemporary are used.
|
||||||
|
func Chmod(name string, mode FileMode) error { return chmod(name, mode) }
|
||||||
|
|
||||||
|
// Chmod changes the mode of the file to mode.
|
||||||
|
// If there is an error, it will be of type *PathError.
|
||||||
|
func (f *File) Chmod(mode FileMode) error { return f.chmod(mode) }
|
||||||
|
@ -196,9 +196,7 @@ func (f *File) Truncate(size int64) error {
|
|||||||
|
|
||||||
const chmodMask = uint32(syscall.DMAPPEND | syscall.DMEXCL | syscall.DMTMP | ModePerm)
|
const chmodMask = uint32(syscall.DMAPPEND | syscall.DMEXCL | syscall.DMTMP | ModePerm)
|
||||||
|
|
||||||
// Chmod changes the mode of the file to mode.
|
func (f *File) chmod(mode FileMode) error {
|
||||||
// If there is an error, it will be of type *PathError.
|
|
||||||
func (f *File) Chmod(mode FileMode) error {
|
|
||||||
if f == nil {
|
if f == nil {
|
||||||
return ErrInvalid
|
return ErrInvalid
|
||||||
}
|
}
|
||||||
@ -375,10 +373,8 @@ func rename(oldname, newname string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Chmod changes the mode of the named file to mode.
|
// See docs in file.go:Chmod.
|
||||||
// If the file is a symbolic link, it changes the mode of the link's target.
|
func chmod(name string, mode FileMode) error {
|
||||||
// If there is an error, it will be of type *PathError.
|
|
||||||
func Chmod(name string, mode FileMode) error {
|
|
||||||
var d syscall.Dir
|
var d syscall.Dir
|
||||||
|
|
||||||
odir, e := dirstat(name)
|
odir, e := dirstat(name)
|
||||||
|
@ -44,19 +44,16 @@ func syscallMode(i FileMode) (o uint32) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Chmod changes the mode of the named file to mode.
|
// See docs in file.go:Chmod.
|
||||||
// If the file is a symbolic link, it changes the mode of the link's target.
|
func chmod(name string, mode FileMode) error {
|
||||||
// If there is an error, it will be of type *PathError.
|
|
||||||
func Chmod(name string, mode FileMode) error {
|
|
||||||
if e := syscall.Chmod(fixLongPath(name), syscallMode(mode)); e != nil {
|
if e := syscall.Chmod(fixLongPath(name), syscallMode(mode)); e != nil {
|
||||||
return &PathError{"chmod", name, e}
|
return &PathError{"chmod", name, e}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Chmod changes the mode of the file to mode.
|
// See docs in file.go:(*File).Chmod.
|
||||||
// If there is an error, it will be of type *PathError.
|
func (f *File) chmod(mode FileMode) error {
|
||||||
func (f *File) Chmod(mode FileMode) error {
|
|
||||||
if err := f.checkValid("chmod"); err != nil {
|
if err := f.checkValid("chmod"); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -69,6 +66,9 @@ func (f *File) Chmod(mode FileMode) error {
|
|||||||
// Chown changes the numeric uid and gid of the named file.
|
// Chown changes the numeric uid and gid of the named file.
|
||||||
// If the file is a symbolic link, it changes the uid and gid of the link's target.
|
// If the file is a symbolic link, it changes the uid and gid of the link's target.
|
||||||
// If there is an error, it will be of type *PathError.
|
// If there is an error, it will be of type *PathError.
|
||||||
|
//
|
||||||
|
// On Windows, it always returns the syscall.EWINDOWS error, wrapped
|
||||||
|
// in *PathError.
|
||||||
func Chown(name string, uid, gid int) error {
|
func Chown(name string, uid, gid int) error {
|
||||||
if e := syscall.Chown(name, uid, gid); e != nil {
|
if e := syscall.Chown(name, uid, gid); e != nil {
|
||||||
return &PathError{"chown", name, e}
|
return &PathError{"chown", name, e}
|
||||||
@ -79,6 +79,9 @@ func Chown(name string, uid, gid int) error {
|
|||||||
// Lchown changes the numeric uid and gid of the named file.
|
// Lchown changes the numeric uid and gid of the named file.
|
||||||
// If the file is a symbolic link, it changes the uid and gid of the link itself.
|
// If the file is a symbolic link, it changes the uid and gid of the link itself.
|
||||||
// If there is an error, it will be of type *PathError.
|
// If there is an error, it will be of type *PathError.
|
||||||
|
//
|
||||||
|
// On Windows, it always returns the syscall.EWINDOWS error, wrapped
|
||||||
|
// in *PathError.
|
||||||
func Lchown(name string, uid, gid int) error {
|
func Lchown(name string, uid, gid int) error {
|
||||||
if e := syscall.Lchown(name, uid, gid); e != nil {
|
if e := syscall.Lchown(name, uid, gid); e != nil {
|
||||||
return &PathError{"lchown", name, e}
|
return &PathError{"lchown", name, e}
|
||||||
@ -88,6 +91,9 @@ func Lchown(name string, uid, gid int) error {
|
|||||||
|
|
||||||
// Chown changes the numeric uid and gid of the named file.
|
// Chown changes the numeric uid and gid of the named file.
|
||||||
// If there is an error, it will be of type *PathError.
|
// If there is an error, it will be of type *PathError.
|
||||||
|
//
|
||||||
|
// On Windows, it always returns the syscall.EWINDOWS error, wrapped
|
||||||
|
// in *PathError.
|
||||||
func (f *File) Chown(uid, gid int) error {
|
func (f *File) Chown(uid, gid int) error {
|
||||||
if err := f.checkValid("chown"); err != nil {
|
if err := f.checkValid("chown"); err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -25,18 +25,29 @@ func init() {
|
|||||||
func runtime_args() []string // in package runtime
|
func runtime_args() []string // in package runtime
|
||||||
|
|
||||||
// Getuid returns the numeric user id of the caller.
|
// Getuid returns the numeric user id of the caller.
|
||||||
|
//
|
||||||
|
// On Windows, it returns -1.
|
||||||
func Getuid() int { return syscall.Getuid() }
|
func Getuid() int { return syscall.Getuid() }
|
||||||
|
|
||||||
// Geteuid returns the numeric effective user id of the caller.
|
// Geteuid returns the numeric effective user id of the caller.
|
||||||
|
//
|
||||||
|
// On Windows, it returns -1.
|
||||||
func Geteuid() int { return syscall.Geteuid() }
|
func Geteuid() int { return syscall.Geteuid() }
|
||||||
|
|
||||||
// Getgid returns the numeric group id of the caller.
|
// Getgid returns the numeric group id of the caller.
|
||||||
|
//
|
||||||
|
// On Windows, it returns -1.
|
||||||
func Getgid() int { return syscall.Getgid() }
|
func Getgid() int { return syscall.Getgid() }
|
||||||
|
|
||||||
// Getegid returns the numeric effective group id of the caller.
|
// Getegid returns the numeric effective group id of the caller.
|
||||||
|
//
|
||||||
|
// On Windows, it returns -1.
|
||||||
func Getegid() int { return syscall.Getegid() }
|
func Getegid() int { return syscall.Getegid() }
|
||||||
|
|
||||||
// Getgroups returns a list of the numeric ids of groups that the caller belongs to.
|
// Getgroups returns a list of the numeric ids of groups that the caller belongs to.
|
||||||
|
//
|
||||||
|
// On Windows, it returns syscall.EWINDOWS. See the os/user package
|
||||||
|
// for a possible alternative.
|
||||||
func Getgroups() ([]int, error) {
|
func Getgroups() ([]int, error) {
|
||||||
gids, e := syscall.Getgroups()
|
gids, e := syscall.Getgroups()
|
||||||
return gids, NewSyscallError("getgroups", e)
|
return gids, NewSyscallError("getgroups", e)
|
||||||
|
@ -45,7 +45,7 @@ const (
|
|||||||
ModeDir FileMode = 1 << (32 - 1 - iota) // d: is a directory
|
ModeDir FileMode = 1 << (32 - 1 - iota) // d: is a directory
|
||||||
ModeAppend // a: append-only
|
ModeAppend // a: append-only
|
||||||
ModeExclusive // l: exclusive use
|
ModeExclusive // l: exclusive use
|
||||||
ModeTemporary // T: temporary file (not backed up)
|
ModeTemporary // T: temporary file; Plan 9 only
|
||||||
ModeSymlink // L: symbolic link
|
ModeSymlink // L: symbolic link
|
||||||
ModeDevice // D: device file
|
ModeDevice // D: device file
|
||||||
ModeNamedPipe // p: named pipe (FIFO)
|
ModeNamedPipe // p: named pipe (FIFO)
|
||||||
|
Loading…
Reference in New Issue
Block a user