Restructure into proper crate.
This commit is contained in:
parent
745328d2ad
commit
65936f8f27
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -1,5 +1,5 @@
|
||||
[root]
|
||||
name = "rust-fat"
|
||||
name = "rustfat"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"byteorder 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -1,5 +1,5 @@
|
||||
[package]
|
||||
name = "rust-fat"
|
||||
name = "rustfat"
|
||||
version = "0.1.0"
|
||||
authors = ["Rafał Harabień <rafalh1992@o2.pl>"]
|
||||
|
||||
|
18
examples/sample.rs
Normal file
18
examples/sample.rs
Normal 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());
|
||||
}
|
||||
}
|
@ -1,11 +1,12 @@
|
||||
use std::io::prelude::*;
|
||||
use std::io;
|
||||
use std::io::Cursor;
|
||||
use std::str;
|
||||
use byteorder::{LittleEndian, ReadBytesExt};
|
||||
use chrono::{DateTime, Date, TimeZone, Local};
|
||||
|
||||
use fs::FatFileSystem;
|
||||
use file::FatFile;
|
||||
use std::io::Cursor;
|
||||
use chrono::{DateTime, Date, TimeZone, Local};
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[allow(dead_code)]
|
||||
|
@ -1,5 +1,6 @@
|
||||
use std::io::prelude::*;
|
||||
use std::io;
|
||||
|
||||
use fs::FatFileSystem;
|
||||
|
||||
#[allow(dead_code)]
|
||||
|
@ -1,8 +1,9 @@
|
||||
use std::io::prelude::*;
|
||||
use std::io::{Error, ErrorKind, SeekFrom};
|
||||
use std::io;
|
||||
use std::str;
|
||||
use std::io::{Error, ErrorKind, SeekFrom};
|
||||
use byteorder::{LittleEndian, ReadBytesExt};
|
||||
|
||||
use file::FatFile;
|
||||
|
||||
// FAT implementation based on:
|
||||
|
13
src/lib.rs
Normal file
13
src/lib.rs
Normal 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::*;
|
30
src/main.rs
30
src/main.rs
@ -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
19
tests/integration-test.rs
Normal 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");
|
||||
}
|
Loading…
Reference in New Issue
Block a user