diff --git a/src/compiler.rs b/src/compiler.rs index 9ab07fc..8b97095 100644 --- a/src/compiler.rs +++ b/src/compiler.rs @@ -3,7 +3,7 @@ use shaderc::{IncludeType, ResolvedInclude}; use shaderc::{ShaderKind, CompileOptions}; use std::fs::File; use std::io::Read; -use std::path::Path; +use std::path::{Path, PathBuf}; pub fn compile(path: T, shader_kind: ShaderKind) -> Result, CompileError> where @@ -34,15 +34,20 @@ where fn get_include( path: &str, include_type: IncludeType, - _folder_path: &str, - _depth: usize, + folder_path: &str, + depth: usize, ) -> Result { match include_type { IncludeType::Relative => { let p = Path::new(path); + let mut folder = PathBuf::from(folder_path); + folder.pop(); + folder.push(p); + let p = folder; if !p.is_file() { return Err("Include doesn't point to file".to_string()); } + let resolved_name = p .to_str() .ok_or("Path has invalid characters".to_string())?