os: add os.stdout() and os.stderr(), returning os.File, similarly to os.stdin() (#9990)

pull/9880/head^2
Leigh McCulloch 2021-05-03 09:00:51 -07:00 committed by GitHub
parent 4ba11b7752
commit 0fa9a648ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 0 deletions

View File

@ -146,6 +146,24 @@ pub fn stdin() File {
}
}
// stdout - return an os.File for stdout
pub fn stdout() File {
return File{
fd: 1
cfile: C.stdout
is_opened: true
}
}
// stderr - return an os.File for stderr
pub fn stderr() File {
return File{
fd: 2
cfile: C.stderr
is_opened: true
}
}
// **************************** Write ops ***************************
// write implements the Writer interface.
// It returns how many bytes were actually written.