os: add file.Truncate

This commit is contained in:
leongross
2024-08-02 08:22:46 -07:00
committed by GitHub
parent 417a26d20c
commit a8a532f9d6
6 changed files with 116 additions and 12 deletions
+14
View File
@@ -59,6 +59,10 @@ func Pipe() (r *File, w *File, err error) {
return
}
func (f *unixFileHandle) Truncate(size int64) error {
return ErrNotImplemented
}
func tempDir() string {
n := uint32(syscall.MAX_PATH)
for {
@@ -106,6 +110,16 @@ func (f unixFileHandle) Sync() error {
return ErrNotImplemented
}
func (f *File) Truncate(size int64) error {
var err error
if f.handle == nil {
err = ErrClosed
} else {
err = ErrNotImplemented
}
return &PathError{Op: "truncate", Path: f.name, Err: err}
}
// isWindowsNulName reports whether name is os.DevNull ('NUL') on Windows.
// True is returned if name is 'NUL' whatever the case.
func isWindowsNulName(name string) bool {