diff --git a/disk_file b/disk_file index 550d34e..8067c5c 100644 Binary files a/disk_file and b/disk_file differ diff --git a/src/drivers/drv_disk.rs b/src/drivers/drv_disk.rs index 3633169..c4fa5d7 100644 --- a/src/drivers/drv_disk.rs +++ b/src/drivers/drv_disk.rs @@ -52,7 +52,7 @@ mod test { } #[test] - fn test_read_write_disk() { + fn test_read_write_drv_disk() { let disk = Disk::init_disk(); let mut drv_disk = DrvDisk::init_drv_disk(disk); diff --git a/src/simulator/disk.rs b/src/simulator/disk.rs index 5499fa1..1d8fddf 100644 --- a/src/simulator/disk.rs +++ b/src/simulator/disk.rs @@ -9,7 +9,7 @@ pub const SECTORS_PER_TRACK: i32 = 32; pub const NUM_TRACKS: i32 = 64; pub const NUM_SECTORS: i32 = SECTORS_PER_TRACK * NUM_TRACKS; pub const SECTOR_SIZE: i32 = 4;//4 octects ? - +pub const DISK_PATH: &str = "disk_file"; pub const MAGIC_NUMBER : u32 = 0xABBACDDC; //taille en octets, a confirmer @@ -33,27 +33,30 @@ impl Disk { let result_open = File::options(). read(true). write(true). - open("disk_file"); + open(DISK_PATH); match result_open { Err(e) => { //On creer le fichier et on y écrit le magic number - let magic_to_write : [u8 ; 5] = [0xAB, 0xBA, 0xCD, 0xDC, 0]; + let magic_to_write : [u8 ; 4] = [0xAB, 0xBA, 0xCD, 0xDC]; println!("Error opening file : {}", e); disk_file = File::options(). read(true). write(true). create_new(true). - open("disk_file").unwrap(); + open(DISK_PATH).unwrap(); disk_file.write_at(&magic_to_write[..], 0); } Ok(f) => { disk_file = f; + let magic_to_write : [u8 ; 5] = [0xAB, 0xBA, 0xCD, 0xDC, 0]; + disk_file.write_at(&magic_to_write[..], 0); } + } match disk_file.read_at(&mut magic_buff[..], 0) { @@ -105,7 +108,7 @@ impl Disk { } disk.active = true; - let mut f = File::open("test/disk.txt")?; + let mut f = File::open(DISK_PATH)?; f.seek(SeekFrom::Start((sector_number * SECTOR_SIZE) as u64))?; let mut buffer = [0; SECTOR_SIZE as usize]; f.read(&mut buffer)?; @@ -138,7 +141,7 @@ impl Disk { } disk.active = true; - let mut f = File::create("test/disk.txt")?; + let mut f = File::create(DISK_PATH)?; f.seek(SeekFrom::Start((sector_number * SECTOR_SIZE) as u64))?; let mut i = 0; let mut buff = Vec::new();