library: os.File.Close
This commit is contained in:
@@ -16,13 +16,10 @@ import (
|
|||||||
// be canceled and return immediately with an ErrClosed error.
|
// be canceled and return immediately with an ErrClosed error.
|
||||||
// Close will return an error if it has already been called.
|
// Close will return an error if it has already been called.
|
||||||
func (f *File) Close() error {
|
func (f *File) Close() error {
|
||||||
/*
|
if f == nil {
|
||||||
if f == nil {
|
return ErrInvalid
|
||||||
return ErrInvalid
|
}
|
||||||
}
|
return f.close()
|
||||||
return f.file.close()
|
|
||||||
*/
|
|
||||||
panic("todo: os.(*File).Close")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// pread reads len(b) bytes from the File starting at byte offset off.
|
// pread reads len(b) bytes from the File starting at byte offset off.
|
||||||
|
|||||||
@@ -250,6 +250,27 @@ func openFileNolog(name string, flag int, perm FileMode) (*File, error) {
|
|||||||
return f, nil
|
return f, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (file *File) close() error {
|
||||||
|
return syscall.Close(int(file.fd))
|
||||||
|
/* TODO(xsw):
|
||||||
|
if file.dirinfo != nil {
|
||||||
|
file.dirinfo.close()
|
||||||
|
file.dirinfo = nil
|
||||||
|
}
|
||||||
|
var err error
|
||||||
|
if e := file.pfd.Close(); e != nil {
|
||||||
|
if e == poll.ErrFileClosing {
|
||||||
|
e = ErrClosed
|
||||||
|
}
|
||||||
|
err = &PathError{Op: "close", Path: file.name, Err: e}
|
||||||
|
}
|
||||||
|
|
||||||
|
// no need for a finalizer anymore
|
||||||
|
runtime.SetFinalizer(file, nil)
|
||||||
|
return err
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
func tempDir() string {
|
func tempDir() string {
|
||||||
dir := Getenv("TMPDIR")
|
dir := Getenv("TMPDIR")
|
||||||
if dir == "" {
|
if dir == "" {
|
||||||
|
|||||||
Reference in New Issue
Block a user