mirror of
https://github.com/wichtounet/thor-os.git
synced 2025-09-18 17:15:09 -04:00
Optimize read to only read the hierarchy once
This commit is contained in:
parent
6e7f1b588d
commit
b6337900af
@ -495,6 +495,8 @@ std::string fat32::read_file(dd disk, const disks::partition_descriptor& partiti
|
||||
return {};
|
||||
}
|
||||
|
||||
uint32_t cluster_number;
|
||||
|
||||
size_t file_size = 0;
|
||||
auto found = false;
|
||||
auto all_files = files(disk, path);
|
||||
@ -502,6 +504,7 @@ std::string fat32::read_file(dd disk, const disks::partition_descriptor& partiti
|
||||
if(f.file_name == file){
|
||||
found = true;
|
||||
file_size = f.size;
|
||||
cluster_number = f.location;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -510,20 +513,6 @@ std::string fat32::read_file(dd disk, const disks::partition_descriptor& partiti
|
||||
return {};
|
||||
}
|
||||
|
||||
std::vector<std::string> complete_path;
|
||||
for(auto& p : path){
|
||||
complete_path.push_back(p);
|
||||
}
|
||||
complete_path.push_back(file);
|
||||
|
||||
auto cluster_number_search = find_cluster_number(disk, complete_path);
|
||||
|
||||
if(!cluster_number_search.first){
|
||||
return {};
|
||||
}
|
||||
|
||||
auto cluster_number = cluster_number_search.second;
|
||||
|
||||
std::string content(file_size + 1);
|
||||
|
||||
size_t read = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user