pub(crate) fn load_context_directory(&mut self) {
if let Some(load_context) = self.load_contexts.last() {
if let Some(directory) = load_context.path.parent() {
- // canonicalize returns the absolute path of the directory.
- let directory = directory.canonicalize().unwrap();
let directory_str = directory.to_str().unwrap();
let directory_atom =
impl LoadContext {
#[inline]
fn new(path: &str, stream: Stream) -> Self {
+ let mut path_buf = PathBuf::from(path);
+
+ if path_buf.is_relative() {
+ let mut current_dir = current_dir();
+ current_dir.push(path_buf);
+ path_buf = current_dir;
+ }
+
LoadContext {
- path: PathBuf::from(path),
+ path: path_buf,
stream,
module: clause_name!("user"),
}
}
#[inline]
-fn current_dir() -> std::path::PathBuf {
- let mut path_buf = std::path::PathBuf::from(file!());
-
- path_buf.pop();
- path_buf
+fn current_dir() -> PathBuf {
+ PathBuf::from("./").canonicalize().unwrap_or(PathBuf::from("./"))
}
include!(concat!(env!("OUT_DIR"), "/libraries.rs"));