mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-14 07:53:40 +00:00
os/file: add file.Chmod
Signed-off-by: leongross <leon.gross@9elements.com>
This commit is contained in:
@@ -307,6 +307,17 @@ func (f *File) Sync() (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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) (err error) {
|
||||||
|
if f.handle == nil {
|
||||||
|
err = ErrClosed
|
||||||
|
} else {
|
||||||
|
err = f.chmod(mode)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// LinkError records an error during a link or symlink or rename system call and
|
// LinkError records an error during a link or symlink or rename system call and
|
||||||
// the paths that caused it.
|
// the paths that caused it.
|
||||||
type LinkError struct {
|
type LinkError struct {
|
||||||
|
|||||||
@@ -149,3 +149,7 @@ func (f *File) Truncate(size int64) (err error) {
|
|||||||
|
|
||||||
return Truncate(f.name, size)
|
return Truncate(f.name, size)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (f *File) chmod(mode FileMode) error {
|
||||||
|
return ErrUnsupported
|
||||||
|
}
|
||||||
|
|||||||
@@ -151,6 +151,21 @@ func (f *File) Truncate(size int64) (err error) {
|
|||||||
return Truncate(f.name, size)
|
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.
|
// 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.
|
// It returns the number of bytes read and any error encountered, possibly io.EOF.
|
||||||
// At end of file, Pread returns 0, io.EOF.
|
// At end of file, Pread returns 0, io.EOF.
|
||||||
|
|||||||
@@ -142,3 +142,7 @@ func isWindowsNulName(name string) bool {
|
|||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (f *File) chmod(mode FileMode) error {
|
||||||
|
return ErrNotImplemented
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user