Skip to content

Commit d8bcdf7

Browse files
thejpsterjonathanpallant
authored andcommitted
Rename FileNotFound to NotFound
Sometimes you get this error if a *directory* was not found, so it was confusing.
1 parent e7ef46f commit d8bcdf7

File tree

5 files changed

+18
-18
lines changed

5 files changed

+18
-18
lines changed

src/fat/volume.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ impl FatVolume {
575575
match_name,
576576
block,
577577
) {
578-
Err(Error::FileNotFound) => continue,
578+
Err(Error::NotFound) => continue,
579579
x => return x,
580580
}
581581
}
@@ -592,7 +592,7 @@ impl FatVolume {
592592
current_cluster = None;
593593
}
594594
}
595-
Err(Error::FileNotFound)
595+
Err(Error::NotFound)
596596
}
597597
FatSpecificInfo::Fat32(fat32_info) => {
598598
let mut current_cluster = match dir.cluster {
@@ -609,7 +609,7 @@ impl FatVolume {
609609
match_name,
610610
block,
611611
) {
612-
Err(Error::FileNotFound) => continue,
612+
Err(Error::NotFound) => continue,
613613
x => return x,
614614
}
615615
}
@@ -619,7 +619,7 @@ impl FatVolume {
619619
_ => None,
620620
}
621621
}
622-
Err(Error::FileNotFound)
622+
Err(Error::NotFound)
623623
}
624624
}
625625
}
@@ -653,7 +653,7 @@ impl FatVolume {
653653
return Ok(dir_entry.get_entry(fat_type, block, start));
654654
}
655655
}
656-
Err(Error::FileNotFound)
656+
Err(Error::NotFound)
657657
}
658658

659659
/// Delete an entry from the given directory
@@ -691,7 +691,7 @@ impl FatVolume {
691691
// Scan the cluster / root dir a block at a time
692692
for block in first_dir_block_num.range(dir_size) {
693693
match self.delete_entry_in_block(block_device, match_name, block) {
694-
Err(Error::FileNotFound) => {
694+
Err(Error::NotFound) => {
695695
// Carry on
696696
}
697697
x => {
@@ -731,7 +731,7 @@ impl FatVolume {
731731
let block_idx = self.cluster_to_block(cluster);
732732
for block in block_idx.range(BlockCount(u32::from(self.blocks_per_cluster))) {
733733
match self.delete_entry_in_block(block_device, match_name, block) {
734-
Err(Error::FileNotFound) => {
734+
Err(Error::NotFound) => {
735735
// Carry on
736736
continue;
737737
}
@@ -755,7 +755,7 @@ impl FatVolume {
755755
}
756756
// If we get here we never found the right entry in any of the
757757
// blocks that made up the directory
758-
Err(Error::FileNotFound)
758+
Err(Error::NotFound)
759759
}
760760

761761
/// Deletes a directory entry from a block of directory entries.
@@ -790,7 +790,7 @@ impl FatVolume {
790790
.map_err(Error::DeviceError);
791791
}
792792
}
793-
Err(Error::FileNotFound)
793+
Err(Error::NotFound)
794794
}
795795

796796
/// Finds the next free cluster after the start_cluster and before end_cluster

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,8 @@ where
159159
TooManyOpenFiles,
160160
/// Bad handle given
161161
BadHandle,
162-
/// That file doesn't exist
163-
FileNotFound,
162+
/// That file or directory doesn't exist
163+
NotFound,
164164
/// You can't open a file twice or delete an open file
165165
FileAlreadyOpen,
166166
/// You can't open a directory twice

src/volume_mgr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ where
493493
}
494494
_ => {
495495
// We are opening a non-existant file, and that's not OK.
496-
return Err(Error::FileNotFound);
496+
return Err(Error::NotFound);
497497
}
498498
};
499499

@@ -905,7 +905,7 @@ where
905905
Ok(_entry) => {
906906
return Err(Error::FileAlreadyExists);
907907
}
908-
Err(Error::FileNotFound) => {
908+
Err(Error::NotFound) => {
909909
// perfect, let's make it
910910
}
911911
Err(e) => {

tests/directories.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ fn find_dir_entry() {
316316

317317
assert!(matches!(
318318
volume_mgr.find_directory_entry(root_dir, "README.TXS"),
319-
Err(embedded_sdmmc::Error::FileNotFound)
319+
Err(embedded_sdmmc::Error::NotFound)
320320
));
321321
}
322322

@@ -345,7 +345,7 @@ fn delete_file() {
345345

346346
assert!(matches!(
347347
volume_mgr.delete_file_in_dir(root_dir, "README2.TXT"),
348-
Err(embedded_sdmmc::Error::FileNotFound)
348+
Err(embedded_sdmmc::Error::NotFound)
349349
));
350350

351351
volume_mgr.close_file(file).unwrap();
@@ -356,12 +356,12 @@ fn delete_file() {
356356

357357
assert!(matches!(
358358
volume_mgr.delete_file_in_dir(root_dir, "README.TXT"),
359-
Err(embedded_sdmmc::Error::FileNotFound)
359+
Err(embedded_sdmmc::Error::NotFound)
360360
));
361361

362362
assert!(matches!(
363363
volume_mgr.open_file_in_dir(root_dir, "README.TXT", Mode::ReadOnly),
364-
Err(embedded_sdmmc::Error::FileNotFound)
364+
Err(embedded_sdmmc::Error::NotFound)
365365
));
366366
}
367367

tests/open_files.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ fn open_files() {
6767

6868
assert!(matches!(
6969
volume_mgr.open_file_in_dir(root_dir, "README.TXS", Mode::ReadOnly),
70-
Err(Error::FileNotFound)
70+
Err(Error::NotFound)
7171
));
7272

7373
// Create a new file

0 commit comments

Comments
 (0)