Fix a bug where .write([]) would always fail.
This commit is contained in:
parent
444a16a7e8
commit
a42d2d408a
@ -377,9 +377,8 @@ impl<T: Writer, C> {base: T, cleanup: C}: Writer {
|
||||
impl *libc::FILE: Writer {
|
||||
fn write(v: &[const u8]) {
|
||||
do vec::as_const_buf(v) |vbuf, len| {
|
||||
let nout = libc::fwrite(vbuf as *c_void, len as size_t,
|
||||
1u as size_t, self);
|
||||
if nout < 1 as size_t {
|
||||
let nout = libc::fwrite(vbuf as *c_void, 1, len as size_t, self);
|
||||
if nout != len as size_t {
|
||||
error!("error writing buffer");
|
||||
log(error, os::last_os_error());
|
||||
fail;
|
||||
@ -959,6 +958,13 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_write_empty() {
|
||||
let file = io::file_writer(&Path("tmp/lib-io-test-write-empty.tmp"),
|
||||
[io::Create]).get();
|
||||
file.write([]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn file_writer_bad_name() {
|
||||
match io::file_writer(&Path("?/?"), ~[]) {
|
||||
|
Loading…
Reference in New Issue
Block a user