net/os: deprecate write_str() in favor of write_string()

pull/9368/head
Alexander Medvednikov 2021-03-19 04:51:31 +03:00
parent 8fa7e67000
commit bb79df932b
2 changed files with 8 additions and 7 deletions

View File

@ -67,10 +67,16 @@ pub fn (mut c TcpConn) write(bytes []byte) ?int {
}
// write_str blocks and attempts to write all data
[deprecated: 'use TcpConn.write_string() instead']
pub fn (mut c TcpConn) write_str(s string) ?int {
return c.write_ptr(s.str, s.len)
}
// write_string blocks and attempts to write all data
pub fn (mut c TcpConn) write_string(s string) ?int {
return c.write_ptr(s.str, s.len)
}
pub fn (mut c TcpConn) read_ptr(buf_ptr byteptr, len int) ?int {
mut res := wrap_read_result(C.recv(c.sock.handle, buf_ptr, len, 0)) ?
$if trace_tcp ? {

View File

@ -311,14 +311,9 @@ pub fn (mut f File) flush() {
// write_str writes the bytes of a string into a file,
// *including* the terminating 0 byte.
[deprecated: 'use File.write_string() instead']
pub fn (mut f File) write_str(s string) ? {
if !f.is_opened {
return error('file is closed')
}
written := int(C.fwrite(voidptr(s.str), s.len, 1, f.cfile))
if written == 0 && s.len != 0 {
return error('0 bytes written')
}
f.write_string(s) or { return err }
}
// read_struct reads a single struct of type `T`