fn get_path()

in src/source.rs [68:92]


    fn get_path(
        platform: Platform,
        canonicalize: bool,
        compilation_dir: &[u8],
        file: &FileInfo,
    ) -> String {
        let mut dir = file.dir_str().to_string();
        let name = file.name_str();
        if !platform.is_absolute_path(&dir) && !compilation_dir.is_empty() {
            let comp_dir = Self::path_to_string(compilation_dir);
            dir = platform.join_paths(&comp_dir, &dir);
        };
        let path = platform.join_paths(&dir, &name);

        if canonicalize {
            // Try to get the real path and in case we're on the machine where the files have been compiled
            // else fallback on the basic way to normalize a path
            let path = PathBuf::from(path);
            let path = fs::canonicalize(&path).unwrap_or_else(|_| utils::normalize_path(&path));
            path.to_string_lossy().to_string()
        } else {
            // Don't attempt to normalize the path if we're on a different platform.
            path
        }
    }