本文整理匯總了Golang中syscall.Fwstat函數的典型用法代碼示例。如果您正苦於以下問題:Golang Fwstat函數的具體用法?Golang Fwstat怎麽用?Golang Fwstat使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Fwstat函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Chmod
// 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
}
示例2: Truncate
// 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
}
示例3: Chmod
// 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
}
示例4: Sync
// 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
}
示例5: Chmod
// 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
}