Mark the image files for copying.

This commit is contained in:
Tom Alexander 2025-02-08 19:23:19 -05:00
parent ff478253c3
commit bf7f37260c
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
3 changed files with 21 additions and 5 deletions

View File

@ -3,6 +3,8 @@ use std::path::PathBuf;
use crate::error::CustomError; use crate::error::CustomError;
use super::dependency::Dependency;
pub(crate) type RefDependencyManager = std::sync::Arc<std::sync::Mutex<DependencyManager>>; pub(crate) type RefDependencyManager = std::sync::Arc<std::sync::Mutex<DependencyManager>>;
#[derive(Debug)] #[derive(Debug)]
@ -11,12 +13,15 @@ pub(crate) struct DependencyManager {
/// ///
/// The last entry is the current file being processed. This can be used for handling relative-path links. /// The last entry is the current file being processed. This can be used for handling relative-path links.
file_stack: Vec<PathBuf>, file_stack: Vec<PathBuf>,
dependencies: Vec<Dependency>,
} }
impl DependencyManager { impl DependencyManager {
pub(crate) fn new() -> Self { pub(crate) fn new() -> Self {
DependencyManager { DependencyManager {
file_stack: Vec::new(), file_stack: Vec::new(),
dependencies: Vec::new(),
} }
} }
@ -43,4 +48,14 @@ impl DependencyManager {
.parent() .parent()
.ok_or("Current file was not in a directory")?) .ok_or("Current file was not in a directory")?)
} }
pub(crate) fn mark_file_for_copying<P>(&mut self, path: P) -> Result<(), CustomError>
where
P: Into<PathBuf>,
{
self.dependencies.push(Dependency::StaticFile {
absolute_path: path.into(),
});
Ok(())
}
} }

View File

@ -11,6 +11,7 @@ mod clock;
mod code; mod code;
mod comment; mod comment;
mod comment_block; mod comment_block;
mod dependency;
mod dependency_manager; mod dependency_manager;
mod diary_sexp; mod diary_sexp;
mod document_element; mod document_element;

View File

@ -153,17 +153,17 @@ impl LinkTarget {
.canonicalize()?; .canonicalize()?;
let input_root_directory = render_context.config.get_root_directory(); let input_root_directory = render_context.config.get_root_directory();
let relative_path_to_file = path_to_file.strip_prefix(input_root_directory)?; let relative_path_to_file = path_to_file.strip_prefix(input_root_directory)?;
dbg!(input_root_directory);
dbg!(&path_to_file);
dbg!(relative_path_to_file);
let web_path = get_web_path( let web_path = get_web_path(
render_context.config, render_context.config,
render_context.output_root_directory, render_context.output_root_directory,
render_context.output_file, render_context.output_file,
relative_path_to_file, relative_path_to_file,
)?; )?;
dbg!(&web_path); let path_to_file = render_context
// TODO: Record interest in copying the file to output. .dependency_manager
.lock()
.unwrap()
.mark_file_for_copying(path_to_file)?;
Ok(Some(web_path)) Ok(Some(web_path))
} }
} }