summaryrefslogtreecommitdiff
path: root/src/policy.rs
blob: e24bf8f94f454493dc8c4708375b80f9178dddb7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use std::path::{Component, Path, PathBuf};

/// Get the base directory given the name of the markdown file.
///
/// All relative filename, such as bindings files, are resolved
/// against the base directory.
pub fn get_basedir_from(filename: &Path) -> PathBuf {
    match filename.parent() {
        None => {
            let p = Component::CurDir;
            let p: &Path = p.as_ref();
            p.to_path_buf()
        }
        Some(x) => x.to_path_buf(),
    }
}