Crate cfile [] [src]

Examples

use std::io::prelude::*;
use std::io::{BufReader, SeekFrom};

use cfile;

// open a tempfile
let mut f = cfile::tmpfile().unwrap();

// write something to the stream
assert_eq!(f.write(b"test").unwrap(), 4);

// force to flush the stream
f.flush().unwrap();

// seek to the beginning of stream
assert_eq!(f.seek(SeekFrom::Start(0)).unwrap(), 0);

let mut r = BufReader::new(f);
let mut s = String::new();

// read back the text
assert_eq!(r.read_line(&mut s).unwrap(), 4);
assert_eq!(s, "test");

Structs

CFile

A reference to an open stream on the filesystem.

FileLock

A locked reference to the CFile stream.

RawFile

Raw file stream.

Traits

FileLockExt

Extension methods for CFile lock.

Stream

C *FILE stream

ToStream

Functions

open

opens the file whose name is the string pointed to by filename and associates a stream with it.

open_stream

associates a stream with the existing file descriptor.

stderr

open stderr as a write only stream

stdin

open stdin as a read only stream

stdout

open stdout as a write only stream

tmpfile

open a temporary file as a read/write stream

Type Definitions

RawFilePtr

Raw C *FILE stream.