mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-20 04:19:04 +00:00
os/File: add stubs for os.File Deadlines (#4465)
os/File: add stubs for os.File Deadlines * add os.SetDeadline, os.SetReadDeadline, os.SetWriteDeadline stubs for posix files. * deadline: add tests Signed-off-by: leongross <leon.gross@9elements.com>
This commit is contained in:
@@ -257,12 +257,29 @@ func (f *File) SyscallConn() (conn syscall.RawConn, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
// SetDeadline sets the read and write deadlines for a File.
|
||||
// Calls to SetDeadline for files that do not support deadlines will return ErrNoDeadline
|
||||
// This stub always returns ErrNoDeadline.
|
||||
// A zero value for t means I/O operations will not time out.
|
||||
func (f *File) SetDeadline(t time.Time) error {
|
||||
if f.handle == nil {
|
||||
return ErrClosed
|
||||
}
|
||||
return f.setDeadline(t)
|
||||
}
|
||||
|
||||
// SetReadDeadline sets the deadline for future Read calls and any
|
||||
// currently-blocked Read call.
|
||||
func (f *File) SetReadDeadline(t time.Time) error {
|
||||
return f.setReadDeadline(t)
|
||||
}
|
||||
|
||||
// SetWriteDeadline sets the deadline for any future Write calls and any
|
||||
// currently-blocked Write call.
|
||||
func (f *File) SetWriteDeadline(t time.Time) error {
|
||||
return f.setWriteDeadline(t)
|
||||
}
|
||||
|
||||
// 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 {
|
||||
|
||||
Reference in New Issue
Block a user