os/file: add file.Chmod

Signed-off-by: leongross <leon.gross@9elements.com>
This commit is contained in:
leongross
2025-02-14 17:15:41 +01:00
committed by Ron Evans
parent c1b267a208
commit 2d17dec7bf
4 changed files with 34 additions and 0 deletions
+15
View File
@@ -151,6 +151,21 @@ func (f *File) Truncate(size int64) (err error) {
return Truncate(f.name, size)
}
func (f *File) chmod(mode FileMode) error {
if f.handle == nil {
return ErrClosed
}
longName := fixLongPath(f.name)
e := ignoringEINTR(func() error {
return syscall.Chmod(longName, syscallMode(mode))
})
if e != nil {
return &PathError{Op: "chmod", Path: f.name, Err: e}
}
return nil
}
// ReadAt reads up to len(b) bytes from the File starting at the given absolute offset.
// It returns the number of bytes read and any error encountered, possibly io.EOF.
// At end of file, Pread returns 0, io.EOF.