vfs: Make file handles compatible with OS

* Implement directory handles
  * Unify OpenFile
  * Add all the methods to match *os.File
  * Add StatParent and Rename methods to VFS
This commit is contained in:
Nick Craig-Wood 2017-10-29 21:11:17 +00:00
parent 3e0c91ba4b
commit a5dc62f6c1
5 changed files with 243 additions and 0 deletions

View file

@ -2,6 +2,7 @@ package vfs
import (
"io"
"os"
"sync"
"time"
@ -10,6 +11,7 @@ import (
// WriteFileHandle is an open for write handle on a File
type WriteFileHandle struct {
baseHandle
mu sync.Mutex
closed bool // set if handle has been closed
remote string
@ -195,6 +197,11 @@ func (fh *WriteFileHandle) Release() error {
return err
}
// Stat returns info about the file
func (fh *WriteFileHandle) Stat() (os.FileInfo, error) {
return fh.file, nil
}
// Close closes the file calling Flush then Release
func (fh *WriteFileHandle) Close() error {
err := fh.Flush()