2013-03-13 22:02:48 -05:00
|
|
|
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
|
|
|
use prelude::*;
|
2013-04-19 17:18:38 -05:00
|
|
|
use super::support::PathLike;
|
2013-04-24 20:26:49 -05:00
|
|
|
use super::{Reader, Writer, Seek};
|
2013-04-24 14:11:33 -05:00
|
|
|
use super::SeekStyle;
|
2013-04-17 19:55:21 -05:00
|
|
|
|
2013-07-12 16:43:57 -05:00
|
|
|
/// # FIXME #7785
|
2013-04-17 19:55:21 -05:00
|
|
|
/// * Ugh, this is ridiculous. What is the best way to represent these options?
|
|
|
|
enum FileMode {
|
|
|
|
/// Opens an existing file. IoError if file does not exist.
|
|
|
|
Open,
|
|
|
|
/// Creates a file. IoError if file exists.
|
|
|
|
Create,
|
|
|
|
/// Opens an existing file or creates a new one.
|
|
|
|
OpenOrCreate,
|
|
|
|
/// Opens an existing file or creates a new one, positioned at EOF.
|
|
|
|
Append,
|
|
|
|
/// Opens an existing file, truncating it to 0 bytes.
|
|
|
|
Truncate,
|
|
|
|
/// Opens an existing file or creates a new one, truncating it to 0 bytes.
|
|
|
|
CreateOrTruncate,
|
|
|
|
}
|
2013-04-19 14:04:19 -05:00
|
|
|
|
2013-04-17 19:55:21 -05:00
|
|
|
enum FileAccess {
|
|
|
|
Read,
|
|
|
|
Write,
|
|
|
|
ReadWrite
|
|
|
|
}
|
2013-03-13 22:02:48 -05:00
|
|
|
|
|
|
|
pub struct FileStream;
|
|
|
|
|
2013-04-17 19:55:21 -05:00
|
|
|
impl FileStream {
|
|
|
|
pub fn open<P: PathLike>(_path: &P,
|
|
|
|
_mode: FileMode,
|
|
|
|
_access: FileAccess
|
2013-04-22 15:10:59 -05:00
|
|
|
) -> Option<FileStream> {
|
2013-03-13 22:02:48 -05:00
|
|
|
fail!()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-17 19:55:21 -05:00
|
|
|
impl Reader for FileStream {
|
|
|
|
fn read(&mut self, _buf: &mut [u8]) -> Option<uint> {
|
2013-03-13 22:02:48 -05:00
|
|
|
fail!()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn eof(&mut self) -> bool {
|
|
|
|
fail!()
|
|
|
|
}
|
2013-04-17 19:55:21 -05:00
|
|
|
}
|
2013-03-13 22:02:48 -05:00
|
|
|
|
2013-04-17 19:55:21 -05:00
|
|
|
impl Writer for FileStream {
|
|
|
|
fn write(&mut self, _v: &[u8]) { fail!() }
|
|
|
|
|
|
|
|
fn flush(&mut self) { fail!() }
|
|
|
|
}
|
|
|
|
|
2013-04-19 16:58:21 -05:00
|
|
|
impl Seek for FileStream {
|
2013-04-17 19:55:21 -05:00
|
|
|
fn tell(&self) -> u64 { fail!() }
|
|
|
|
|
|
|
|
fn seek(&mut self, _pos: i64, _style: SeekStyle) { fail!() }
|
|
|
|
}
|
|
|
|
|
2013-03-13 22:02:48 -05:00
|
|
|
#[test]
|
|
|
|
#[ignore]
|
|
|
|
fn super_simple_smoke_test_lets_go_read_some_files_and_have_a_good_time() {
|
|
|
|
let message = "it's alright. have a good time";
|
2013-04-17 19:55:21 -05:00
|
|
|
let filename = &Path("test.txt");
|
|
|
|
let mut outstream = FileStream::open(filename, Create, Read).unwrap();
|
2013-06-10 22:10:37 -05:00
|
|
|
outstream.write(message.as_bytes());
|
2013-03-13 22:02:48 -05:00
|
|
|
}
|