Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

15 lib.rs
@@ -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};
@@ -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"),
};
@@ -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")
};
@@ -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"),
};
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.