Skip to content

Commit f5bafa5

Browse files
committed
Ensure DirectoryInfo values are called dir_info
1 parent 41cbb62 commit f5bafa5

File tree

2 files changed

+29
-26
lines changed

2 files changed

+29
-26
lines changed

src/fat/volume.rs

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ impl FatVolume {
538538
pub(crate) fn iterate_dir<D, F>(
539539
&self,
540540
block_device: &D,
541-
dir: &DirectoryInfo,
541+
dir_info: &DirectoryInfo,
542542
func: F,
543543
) -> Result<(), Error<D::Error>>
544544
where
@@ -547,17 +547,17 @@ impl FatVolume {
547547
{
548548
match &self.fat_specific_info {
549549
FatSpecificInfo::Fat16(fat16_info) => {
550-
self.iterate_fat16(dir, fat16_info, block_device, func)
550+
self.iterate_fat16(dir_info, fat16_info, block_device, func)
551551
}
552552
FatSpecificInfo::Fat32(fat32_info) => {
553-
self.iterate_fat32(dir, fat32_info, block_device, func)
553+
self.iterate_fat32(dir_info, fat32_info, block_device, func)
554554
}
555555
}
556556
}
557557

558558
fn iterate_fat16<D, F>(
559559
&self,
560-
dir: &DirectoryInfo,
560+
dir_info: &DirectoryInfo,
561561
fat16_info: &Fat16Info,
562562
block_device: &D,
563563
mut func: F,
@@ -570,12 +570,12 @@ impl FatVolume {
570570
// a specially reserved space on disk (see
571571
// `first_root_dir_block`). Other directories can have any size
572572
// as they are made of regular clusters.
573-
let mut current_cluster = Some(dir.cluster);
574-
let mut first_dir_block_num = match dir.cluster {
573+
let mut current_cluster = Some(dir_info.cluster);
574+
let mut first_dir_block_num = match dir_info.cluster {
575575
ClusterId::ROOT_DIR => self.lba_start + fat16_info.first_root_dir_block,
576-
_ => self.cluster_to_block(dir.cluster),
576+
_ => self.cluster_to_block(dir_info.cluster),
577577
};
578-
let dir_size = match dir.cluster {
578+
let dir_size = match dir_info.cluster {
579579
ClusterId::ROOT_DIR => {
580580
let len_bytes = u32::from(fat16_info.root_entries_count) * OnDiskDirEntry::LEN_U32;
581581
BlockCount::from_bytes(len_bytes)
@@ -618,7 +618,7 @@ impl FatVolume {
618618

619619
fn iterate_fat32<D, F>(
620620
&self,
621-
dir: &DirectoryInfo,
621+
dir_info: &DirectoryInfo,
622622
fat32_info: &Fat32Info,
623623
block_device: &D,
624624
mut func: F,
@@ -629,9 +629,9 @@ impl FatVolume {
629629
{
630630
// All directories on FAT32 have a cluster chain but the root
631631
// dir starts in a specified cluster.
632-
let mut current_cluster = match dir.cluster {
632+
let mut current_cluster = match dir_info.cluster {
633633
ClusterId::ROOT_DIR => Some(fat32_info.first_root_dir_cluster),
634-
_ => Some(dir.cluster),
634+
_ => Some(dir_info.cluster),
635635
};
636636
let mut blocks = [Block::new()];
637637
let mut block_cache = BlockCache::empty();
@@ -669,7 +669,7 @@ impl FatVolume {
669669
pub(crate) fn find_directory_entry<D>(
670670
&self,
671671
block_device: &D,
672-
dir: &DirectoryInfo,
672+
dir_info: &DirectoryInfo,
673673
match_name: &ShortFileName,
674674
) -> Result<DirEntry, Error<D::Error>>
675675
where
@@ -681,12 +681,12 @@ impl FatVolume {
681681
// a specially reserved space on disk (see
682682
// `first_root_dir_block`). Other directories can have any size
683683
// as they are made of regular clusters.
684-
let mut current_cluster = Some(dir.cluster);
685-
let mut first_dir_block_num = match dir.cluster {
684+
let mut current_cluster = Some(dir_info.cluster);
685+
let mut first_dir_block_num = match dir_info.cluster {
686686
ClusterId::ROOT_DIR => self.lba_start + fat16_info.first_root_dir_block,
687-
_ => self.cluster_to_block(dir.cluster),
687+
_ => self.cluster_to_block(dir_info.cluster),
688688
};
689-
let dir_size = match dir.cluster {
689+
let dir_size = match dir_info.cluster {
690690
ClusterId::ROOT_DIR => {
691691
let len_bytes =
692692
u32::from(fat16_info.root_entries_count) * OnDiskDirEntry::LEN_U32;
@@ -724,9 +724,9 @@ impl FatVolume {
724724
Err(Error::NotFound)
725725
}
726726
FatSpecificInfo::Fat32(fat32_info) => {
727-
let mut current_cluster = match dir.cluster {
727+
let mut current_cluster = match dir_info.cluster {
728728
ClusterId::ROOT_DIR => Some(fat32_info.first_root_dir_cluster),
729-
_ => Some(dir.cluster),
729+
_ => Some(dir_info.cluster),
730730
};
731731
let mut block_cache = BlockCache::empty();
732732
while let Some(cluster) = current_cluster {
@@ -788,7 +788,7 @@ impl FatVolume {
788788
pub(crate) fn delete_directory_entry<D>(
789789
&self,
790790
block_device: &D,
791-
dir: &DirectoryInfo,
791+
dir_info: &DirectoryInfo,
792792
match_name: &ShortFileName,
793793
) -> Result<(), Error<D::Error>>
794794
where
@@ -800,12 +800,12 @@ impl FatVolume {
800800
// a specially reserved space on disk (see
801801
// `first_root_dir_block`). Other directories can have any size
802802
// as they are made of regular clusters.
803-
let mut current_cluster = Some(dir.cluster);
804-
let mut first_dir_block_num = match dir.cluster {
803+
let mut current_cluster = Some(dir_info.cluster);
804+
let mut first_dir_block_num = match dir_info.cluster {
805805
ClusterId::ROOT_DIR => self.lba_start + fat16_info.first_root_dir_block,
806-
_ => self.cluster_to_block(dir.cluster),
806+
_ => self.cluster_to_block(dir_info.cluster),
807807
};
808-
let dir_size = match dir.cluster {
808+
let dir_size = match dir_info.cluster {
809809
ClusterId::ROOT_DIR => {
810810
let len_bytes =
811811
u32::from(fat16_info.root_entries_count) * OnDiskDirEntry::LEN_U32;
@@ -849,9 +849,9 @@ impl FatVolume {
849849
FatSpecificInfo::Fat32(fat32_info) => {
850850
// Root directories on FAT32 start at a specified cluster, but
851851
// they can have any length.
852-
let mut current_cluster = match dir.cluster {
852+
let mut current_cluster = match dir_info.cluster {
853853
ClusterId::ROOT_DIR => Some(fat32_info.first_root_dir_cluster),
854-
_ => Some(dir.cluster),
854+
_ => Some(dir_info.cluster),
855855
};
856856
// Walk the directory
857857
while let Some(cluster) = current_cluster {

src/volume_mgr.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,9 @@ where
264264
let short_file_name = name.to_short_filename().map_err(Error::FilenameError)?;
265265

266266
// Open the directory
267+
268+
// Should we short-cut? (root dir doesn't have ".")
267269
if short_file_name == ShortFileName::this_dir() {
268-
// short-cut (root dir doesn't have ".")
269270
let directory_id = RawDirectory(data.id_generator.generate());
270271
let dir_info = DirectoryInfo {
271272
raw_directory: directory_id,
@@ -280,6 +281,8 @@ where
280281
return Ok(directory_id);
281282
}
282283

284+
// ok we'll actually look for the directory then
285+
283286
let dir_entry = match &data.open_volumes[volume_idx].volume_type {
284287
VolumeType::Fat(fat) => fat.find_directory_entry(
285288
&self.block_device,

0 commit comments

Comments
 (0)