use crate::{
common::{file::File, pack_path::PackPath},
file, pack_path,
};
use anyhow::{Context, Error};
use std::path::Path;
#[derive(Debug)]
pub struct FilePackPath {
pub file: File,
pub pack_path: PackPath,
}
impl FilePackPath {
pub fn build_from_path(
path: &Path,
base_directory_path: &Path,
file_options: &file::BuildFromPathOptions,
) -> Result<Self, Error> {
let file_base_relative_path = path
.strip_prefix(base_directory_path)
.context("resolve file_base_relative_path")?;
let pack_path = pack_path::from_file_base_relative_path(file_base_relative_path)?;
let file = file::build_from_path(path, file_options)?;
Ok(Self { file, pack_path })
}
}