summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/skaldpress/error.rs2
-rw-r--r--src/skaldpress/main.rs20
2 files changed, 5 insertions, 17 deletions
diff --git a/src/skaldpress/error.rs b/src/skaldpress/error.rs
index 4f16ffa..9c84dd1 100644
--- a/src/skaldpress/error.rs
+++ b/src/skaldpress/error.rs
@@ -5,10 +5,8 @@ use std::fmt;
pub const SP_COMPILE_FILE_TEMPLATE_READ_ERROR: u8 = 2;
pub const SP_COMPILE_FILE_EXTENSION_ERROR_2: u8 = 3;
pub const SP_GEN_DEST_STRIP_PREFIX_ERROR: u8 = 4;
-pub const SP_COMPILE_FILE_EXTENSION_ERROR: u8 = 7;
pub const SP_COMPILE_TEMPLATE_MACRO_PROCESS_ERROR: u8 = 9;
pub const SP_COMPILE_FILE_MACRO_PROCESS_ERROR: u8 = 10;
-pub const SP_COMPILE_FILE_TEMPLATE_EXTENSION_ERROR: u8 = 11;
#[derive(Debug)]
pub enum SkaldpressError {
diff --git a/src/skaldpress/main.rs b/src/skaldpress/main.rs
index 2aa1790..1ad95f9 100644
--- a/src/skaldpress/main.rs
+++ b/src/skaldpress/main.rs
@@ -5,8 +5,7 @@ use std::path::Path;
use skaldpress::macro_processor::MacroProcessor;
use skaldpress::skaldpress::error::SkaldpressError;
use skaldpress::skaldpress::error::{
- SP_COMPILE_FILE_EXTENSION_ERROR, SP_COMPILE_FILE_EXTENSION_ERROR_2,
- SP_COMPILE_FILE_MACRO_PROCESS_ERROR, SP_COMPILE_FILE_TEMPLATE_EXTENSION_ERROR,
+ SP_COMPILE_FILE_EXTENSION_ERROR_2, SP_COMPILE_FILE_MACRO_PROCESS_ERROR,
SP_COMPILE_FILE_TEMPLATE_READ_ERROR, SP_COMPILE_TEMPLATE_MACRO_PROCESS_ERROR,
SP_GEN_DEST_STRIP_PREFIX_ERROR,
};
@@ -25,12 +24,7 @@ struct CompiledFile {
/// Will attempt to compile a specific file, potentially storing some state about the file
fn compile_file(file_path: &Path) -> Result<CompiledFile, SkaldpressError> {
- let extension = file_path
- .extension()
- .ok_or(SkaldpressError::PathOperationError(
- SP_COMPILE_FILE_EXTENSION_ERROR,
- None,
- ))?;
+ let extension = file_path.extension().unwrap_or(std::ffi::OsStr::new(""));
let file_content = fs::read_to_string(file_path).map_err(|e| {
SkaldpressError::FileReadError(
@@ -74,13 +68,9 @@ fn compile_file(file_path: &Path) -> Result<CompiledFile, SkaldpressError> {
template_file.clone(),
)
})?;
- let template_extension =
- Path::new(&template_file)
- .extension()
- .ok_or(SkaldpressError::PathOperationError(
- SP_COMPILE_FILE_TEMPLATE_EXTENSION_ERROR,
- None,
- ))?;
+ let template_extension = Path::new(&template_file)
+ .extension()
+ .unwrap_or(std::ffi::OsStr::new(""));
macro_processor.define_macro_string(String::from("CONTENT"), file_content);
let content = macro_processor