Make imports work on all OSes

This commit is contained in:
0x4261756D 2023-02-06 16:03:48 +01:00
parent 5aa365c681
commit 95133360ee
1 changed files with 16 additions and 22 deletions

View File

@ -304,10 +304,7 @@ fn resolve_imports(tokens: &mut Vec<Token>, functions: &mut Vec<Function>, file_
{
if let Some(Token::StringLit(import_path, _, _)) = tokens_iter.next()
{
match fs::canonicalize(format!("{}/{}", fs::canonicalize(file_path).map_err(|e| e.to_string())?.parent().unwrap_or(&PathBuf::from(".")).display(), import_path))
{
Ok(full_import_path) =>
{
let full_import_path = fs::canonicalize(file_path).map_err(|e| e.to_string())?.parent().unwrap().join(import_path);
if visited_paths.contains(&full_import_path)
{
println!("--Already visited {}--", full_import_path.display());
@ -330,9 +327,6 @@ fn resolve_imports(tokens: &mut Vec<Token>, functions: &mut Vec<Function>, file_
}
}
}
Err(e) => return Err(e.to_string()),
}
}
else
{
return Err(format!("Expected an import location at {}:{}", line, col));