// Truncate changes the size of the file. // It does not change the I/O offset. func (f *File) Truncate(size int64) error { var d Dir d.Null() d.Length = uint64(size) if e := syscall.Fwstat(f.fd, pdir(nil, &d)); e != nil { return &PathError{"truncate", f.name, e} } return nil }
// Chmod changes the mode of the file to mode. func (f *File) Chmod(mode uint32) Error { var d Dir d.Null() d.Mode = mode & 0777 if e := syscall.Fwstat(f.fd, pdir(nil, &d)); iserror(e) { return &PathError{"chmod", f.name, e} } return nil }
// Sync commits the current contents of the file to stable storage. // Typically, this means flushing the file system's in-memory copy // of recently written data to disk. func (f *File) Sync() (err error) { if f == nil { return EINVAL } var d Dir d.Null() if e := syscall.Fwstat(f.fd, pdir(nil, &d)); e != nil { return NewSyscallError("fsync", e) } return nil }
// Chmod changes the mode of the file to mode. func (f *File) Chmod(mode FileMode) error { var d Dir odir, e := dirstat(f) if e != nil { return &PathError{"chmod", f.name, e} } d.Null() d.Mode = odir.Mode&^chmodMask | syscallMode(mode)&chmodMask if e := syscall.Fwstat(f.fd, pdir(nil, &d)); e != nil { return &PathError{"chmod", f.name, e} } return nil }
// Truncate changes the size of the file. // It does not change the I/O offset. // If there is an error, it will be of type *PathError. func (f *File) Truncate(size int64) error { var d syscall.Dir d.Null() d.Length = size var buf [syscall.STATFIXLEN]byte n, err := d.Marshal(buf[:]) if err != nil { return &PathError{"truncate", f.name, err} } if err = syscall.Fwstat(f.fd, buf[:n]); err != nil { return &PathError{"truncate", f.name, err} } return nil }
// Chmod changes the mode of the file to mode. func (f *File) Chmod(mode uint32) error { var d Dir var mask = ^uint32(0777) d.Null() odir, e := dirstat(f) if iserror(e) { return &PathError{"chmod", f.name, e} } d.Mode = (odir.Mode & mask) | (mode &^ mask) if e := syscall.Fwstat(f.fd, pdir(nil, &d)); iserror(e) { return &PathError{"chmod", f.name, e} } return nil }
// Sync commits the current contents of the file to stable storage. // Typically, this means flushing the file system's in-memory copy // of recently written data to disk. func (f *File) Sync() (err error) { if f == nil { return ErrInvalid } var d syscall.Dir d.Null() var buf [syscall.STATFIXLEN]byte n, err := d.Marshal(buf[:]) if err != nil { return NewSyscallError("fsync", err) } if err = syscall.Fwstat(f.fd, buf[:n]); err != nil { return NewSyscallError("fsync", err) } return nil }
// 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 { var d syscall.Dir odir, e := dirstat(f) if e != nil { return &PathError{"chmod", f.name, e} } d.Null() d.Mode = odir.Mode&^chmodMask | syscallMode(mode)&chmodMask var buf [syscall.STATFIXLEN]byte n, err := d.Marshal(buf[:]) if err != nil { return &PathError{"chmod", f.name, err} } if err = syscall.Fwstat(f.fd, buf[:n]); err != nil { return &PathError{"chmod", f.name, err} } return nil }