summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorQrius <[email protected]>2024-09-26 00:11:05 +0200
committerQrius <[email protected]>2024-09-26 00:11:05 +0200
commitba82850b0ea54098b32c7e76d281f6444cbe5522 (patch)
tree2a8be7aad21f6fe7f03fc6ff7951bc2f55c480a4 /src
parenta7ae9cbc56d2a7d36443e6f7f8c51d90ae6fc214 (diff)
downloadskaldpress-ba82850b0ea54098b32c7e76d281f6444cbe5522.tar.gz
skaldpress-ba82850b0ea54098b32c7e76d281f6444cbe5522.zip
Don't fail on files without extensions, simply, don't use extensions
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