patch: os.File

This commit is contained in:
xushiwei
2024-06-27 02:28:18 +08:00
parent 369581976a
commit 2165941026
6 changed files with 474 additions and 133 deletions

View File

@@ -120,6 +120,25 @@ func Chown(name string, uid, gid int) error {
return toPathErr("chown", name, ret)
}
/* TODO(xsw):
// 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.
// A uid or gid of -1 means to not change that value.
// If there is an error, it will be of type *PathError.
//
// On Windows or Plan 9, Chown always returns the syscall.EWINDOWS or
// EPLAN9 error, wrapped in *PathError.
func Chown(name string, uid, gid int) error {
e := ignoringEINTR(func() error {
return syscall.Chown(name, uid, gid)
})
if e != nil {
return &PathError{Op: "chown", Path: name, Err: e}
}
return nil
}
*/
// TODO(xsw):
// func Chtimes(name string, atime time.Time, mtime time.Time) error
@@ -195,6 +214,24 @@ func Lchown(name string, uid, gid int) error {
return toPathErr("lchown", name, ret)
}
/* TODO(xsw):
// 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 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 {
e := ignoringEINTR(func() error {
return syscall.Lchown(name, uid, gid)
})
if e != nil {
return &PathError{Op: "lchown", Path: name, Err: e}
}
return nil
}
*/
func Link(oldname, newname string) error {
ret := os.Link(c.AllocaCStr(oldname), c.AllocaCStr(newname))
if ret == 0 {