Restructure into proper crate.

This commit is contained in:
Rafał Harabień 2017-09-22 23:20:06 +02:00
parent 745328d2ad
commit 65936f8f27
9 changed files with 58 additions and 35 deletions

2
Cargo.lock generated
View File

@ -1,5 +1,5 @@
[root] [root]
name = "rust-fat" name = "rustfat"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"byteorder 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",

View File

@ -1,5 +1,5 @@
[package] [package]
name = "rust-fat" name = "rustfat"
version = "0.1.0" version = "0.1.0"
authors = ["Rafał Harabień <rafalh1992@o2.pl>"] authors = ["Rafał Harabień <rafalh1992@o2.pl>"]

18
examples/sample.rs Normal file
View File

@ -0,0 +1,18 @@
extern crate rustfat;
use std::fs::File;
use std::io::BufReader;
use std::str;
use rustfat::FatFileSystem;
fn main() {
let file = File::open("resources/floppy.img").unwrap();
let mut buf_rdr = BufReader::new(file);
let mut fs = FatFileSystem::new(&mut buf_rdr).unwrap();
let mut root_dir = fs.root_dir();
let entries = fs.read_dir(&mut root_dir).unwrap();
for e in entries {
println!("{} - size {} - modified {}", e.get_name(), e.get_size(), e.get_modify_time());
}
}

View File

@ -1,11 +1,12 @@
use std::io::prelude::*; use std::io::prelude::*;
use std::io; use std::io;
use std::io::Cursor;
use std::str; use std::str;
use byteorder::{LittleEndian, ReadBytesExt}; use byteorder::{LittleEndian, ReadBytesExt};
use chrono::{DateTime, Date, TimeZone, Local};
use fs::FatFileSystem; use fs::FatFileSystem;
use file::FatFile; use file::FatFile;
use std::io::Cursor;
use chrono::{DateTime, Date, TimeZone, Local};
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
#[allow(dead_code)] #[allow(dead_code)]

View File

@ -1,5 +1,6 @@
use std::io::prelude::*; use std::io::prelude::*;
use std::io; use std::io;
use fs::FatFileSystem; use fs::FatFileSystem;
#[allow(dead_code)] #[allow(dead_code)]

View File

@ -1,8 +1,9 @@
use std::io::prelude::*; use std::io::prelude::*;
use std::io::{Error, ErrorKind, SeekFrom};
use std::io; use std::io;
use std::str; use std::str;
use std::io::{Error, ErrorKind, SeekFrom};
use byteorder::{LittleEndian, ReadBytesExt}; use byteorder::{LittleEndian, ReadBytesExt};
use file::FatFile; use file::FatFile;
// FAT implementation based on: // FAT implementation based on:

13
src/lib.rs Normal file
View File

@ -0,0 +1,13 @@
#![crate_type = "lib"]
#![crate_name = "rustfat"]
extern crate byteorder;
extern crate chrono;
pub mod fs;
pub mod dir;
pub mod file;
pub use fs::*;
pub use dir::*;
pub use file::*;

View File

@ -1,30 +0,0 @@
extern crate byteorder;
extern crate chrono;
use std::fs::File;
use std::io::BufReader;
use std::io;
use std::str;
use fs::FatFileSystem;
pub mod fs;
pub mod dir;
pub mod file;
fn fat_test() -> io::Result<()> {
let file = File::open("resources/floppy.img")?;
let mut buf_rdr = BufReader::new(file);
let mut fs = FatFileSystem::new(&mut buf_rdr)?;
let mut root_dir = fs.root_dir();
let entries = fs.read_dir(&mut root_dir)?;
for e in entries {
println!("{} - size {} - modified {}", e.get_name(), e.get_size(), e.get_modify_time());
//println!("name {} size {} cluster {}", name_str, entry.size, entry.first_cluster_lo);
}
Ok(())
}
fn main() {
println!("FAT test!");
fat_test().unwrap();
}

19
tests/integration-test.rs Normal file
View File

@ -0,0 +1,19 @@
extern crate rustfat;
use std::fs::File;
use std::io::BufReader;
use std::str;
use rustfat::FatFileSystem;
#[test]
fn fat12_test() {
let file = File::open("resources/floppy.img").unwrap();
let mut buf_rdr = BufReader::new(file);
let mut fs = FatFileSystem::new(&mut buf_rdr).unwrap();
let mut root_dir = fs.root_dir();
let entries = fs.read_dir(&mut root_dir).unwrap();
assert_eq!(entries.len(), 2);
assert_eq!(entries[0].get_name(), "RAFOS");
assert_eq!(entries[1].get_name(), "GRUB");
}