Skip to content
This repository was archived by the owner on Jul 10, 2023. It is now read-only.

std::rt::io has moved to std::io #14

Merged
merged 2 commits into from
Nov 27, 2013
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
15 changes: 7 additions & 8 deletions lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

extern mod std;
use std::cast;
use std::rt::io;
use std::rt::io::{file, Reader};
use std::io;
use std::io::File;
use std::ptr;
use std::vec;
use std::libc::{c_int, size_t};
Expand Down Expand Up @@ -74,7 +74,7 @@ pub extern fn read_data(png_ptr: *ffi::png_struct, data: *mut u8, length: size_t
}

pub fn load_png(path: &Path) -> Result<Image,~str> {
let mut reader = match file::open(path, io::Open, io::Read) {
let mut reader = match File::open_mode(path, io::Open, io::Read) {
Some(r) => r,
None => return Err(~"could not open file"),
};
Expand Down Expand Up @@ -190,7 +190,7 @@ pub extern fn flush_data(png_ptr: *ffi::png_struct) {

#[fixed_stack_segment]
pub fn store_png(img: &Image, path: &Path) -> Result<(),~str> {
let writer = match file::open(path, io::Create, io::Write) {
let writer = match File::open_mode(path, io::Open, io::Write) {
Some(w) => @mut w as @mut io::Writer,
None => return Err(~"could not open file")
};
Expand Down Expand Up @@ -250,16 +250,15 @@ pub fn store_png(img: &Image, path: &Path) -> Result<(),~str> {

#[cfg(test)]
mod test {
use std::rt::io;
use std::rt::io::Reader;
use std::rt::io::file;
use std::io;
use std::io::File;
use std::vec;
use super::{ffi, load_png, store_png, RGB8, Image};

#[test]
#[fixed_stack_segment]
fn test_valid_png() {
let mut reader = match file::open(& &"test.png", io::Open, io::Read) {
let mut reader = match File::open_mode(&Path::new("test.png"), io::Open, io::Read) {
Some(r) => r,
None => fail!("could not open file"),
};
Expand Down