Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/libcore/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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("?/?"), ~[]) {
Expand Down