mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-13 15:33:40 +00:00
src/os: implement os.File.Fd() method
This commits adds a OS-specific `Fd()` function for `file_anyos.go` and `file_other.go`, which returns a uintptr to the underlying file descriptor.
This commit is contained in:
+11
-1
@@ -179,9 +179,19 @@ func (f *File) SyscallConn() (syscall.RawConn, error) {
|
||||
return nil, ErrNotImplemented
|
||||
}
|
||||
|
||||
// fd is an internal interface that is used to try a type assertion in order to
|
||||
// call the Fd() method of the underlying file handle if it is implemented.
|
||||
type fd interface {
|
||||
Fd() uintptr
|
||||
}
|
||||
|
||||
// Fd returns the file handle referencing the open file.
|
||||
func (f *File) Fd() uintptr {
|
||||
panic("unimplemented: os.file.Fd()")
|
||||
handle, ok := f.handle.(fd)
|
||||
if ok {
|
||||
return handle.Fd()
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// Truncate is a stub, not yet implemented
|
||||
|
||||
Reference in New Issue
Block a user