Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/shim_filesystem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,19 +288,21 @@ cfg_if! {
static IN_MEMORY_DIRS: RwLock<Option<HashSet<String>>> = RwLock::new(None);

pub fn add_in_memory_file(path: &str, content: &str) {
// store the keys the same way they are looked up (get_in_memory_key), so that "/" in 'path'
// still matches on Windows, where the lookup key is built with "\"
let path_obj = Path::new(path);
{
let mut files = IN_MEMORY_FILES.write().unwrap();
files.get_or_insert_with(HashMap::new).insert(path.to_string(), content.to_string());
files.get_or_insert_with(HashMap::new).insert(get_in_memory_key(path_obj), content.to_string());
}

let path_obj = Path::new(path);
{
let mut dirs = IN_MEMORY_DIRS.write().unwrap();
let dirs = dirs.get_or_insert_with(HashSet::new);
for parent in path_obj.ancestors().skip(1) {
let parent_str = parent.to_str().unwrap_or_default();
let parent_str = get_in_memory_key(parent);
if !parent_str.is_empty() {
dirs.insert(parent_str.to_string());
dirs.insert(parent_str);
}
}
}
Expand Down