1#![deny(missing_docs)]
5#![forbid(unsafe_code)]
6
7mod error;
8mod interpreter;
9mod parser;
10
11pub use error::Error;
12pub use interpreter::{CinemaOptions, InterpreterOptions, ScriptFile};
13pub use parser::*;
14
15pub type Result<T> = std::result::Result<T, Error>;
17
18use std::{
19 borrow::Cow,
20 path::{Path, PathBuf},
21};
22
23pub(crate) fn resolve_path(
25 base: impl AsRef<Path>,
26 input: &str,
27) -> Result<Cow<str>> {
28 let path = PathBuf::from(input);
29 if path.is_relative() {
30 if let Some(parent) = base.as_ref().parent() {
31 let new_path = parent.join(input);
32 let path = new_path.canonicalize()?;
33 Ok(Cow::Owned(path.to_string_lossy().as_ref().to_owned()))
34 } else {
35 Ok(Cow::Borrowed(input))
36 }
37 } else {
38 Ok(Cow::Borrowed(input))
39 }
40}