summaryrefslogtreecommitdiff
path: root/src/loading
diff options
context:
space:
mode:
Diffstat (limited to 'src/loading')
-rw-r--r--src/loading/fs.rs7
-rw-r--r--src/loading/mod.rs4
2 files changed, 8 insertions, 3 deletions
diff --git a/src/loading/fs.rs b/src/loading/fs.rs
index d41a7dc1..c3ca332e 100644
--- a/src/loading/fs.rs
+++ b/src/loading/fs.rs
@@ -1,4 +1,4 @@
-use std::cell::RefCell;
+use std::cell::{Ref, RefCell};
use std::collections::HashMap;
use std::fs::{self, File};
use std::io;
@@ -92,6 +92,11 @@ impl FsLoader {
}
}
+ /// Return the path of a resolved file.
+ pub fn path(&self, id: FileId) -> Ref<Path> {
+ Ref::map(self.paths.borrow(), |paths| paths[&id].as_path())
+ }
+
#[cfg(all(unix, not(target_os = "macos")))]
fn search_system_impl(&mut self) {
self.search_path("/usr/share/fonts");
diff --git a/src/loading/mod.rs b/src/loading/mod.rs
index ab52439d..65eb25c6 100644
--- a/src/loading/mod.rs
+++ b/src/loading/mod.rs
@@ -40,12 +40,12 @@ pub struct FileId(u64);
impl FileId {
/// Create a file id from a raw value.
- pub fn from_raw(v: u64) -> Self {
+ pub const fn from_raw(v: u64) -> Self {
Self(v)
}
/// Convert into the raw underlying value.
- pub fn into_raw(self) -> u64 {
+ pub const fn into_raw(self) -> u64 {
self.0
}
}