|
|
@ -2,17 +2,21 @@ |
|
|
|
|
|
|
|
mod common;
|
|
|
|
mod patch;
|
|
|
|
use crate::patch::patch::{PatchServerState, PatchTreeIterItem, generate_patch_tree, PATCH_PORT};
|
|
|
|
use crate::patch::patch::{PatchServerState, PatchTreeIterItem, generate_patch_tree, load_config};
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
println!("[patch] starting server");
|
|
|
|
|
|
|
|
if let Err(_) = std::fs::read_dir("patchfiles/") {
|
|
|
|
if let Err(_) = std::fs::create_dir("patchfiles/") {
|
|
|
|
panic!("Could not create patchfiles directory!");
|
|
|
|
let patch_config = load_config();
|
|
|
|
|
|
|
|
if let Err(_) = std::fs::read_dir(patch_config.path.as_str()) {
|
|
|
|
println!("Patch directory {} does not exist. Attempting to create it...", patch_config.path.as_str());
|
|
|
|
if let Err(err) = std::fs::create_dir(patch_config.path.as_str()) {
|
|
|
|
panic!("Failed to create patch directory! \n{}", err);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
let (patch_file_tree, patch_file_lookup) = generate_patch_tree("patchfiles/");
|
|
|
|
|
|
|
|
let (patch_file_tree, patch_file_lookup) = generate_patch_tree(patch_config.path.as_str());
|
|
|
|
println!("[patch] files to patch:");
|
|
|
|
let mut indent = 0;
|
|
|
|
for item in patch_file_tree.flatten() {
|
|
|
@ -33,7 +37,7 @@ fn main() { |
|
|
|
}
|
|
|
|
|
|
|
|
let patch_state = PatchServerState::new(patch_file_tree, patch_file_lookup);
|
|
|
|
common::mainloop::mainloop(patch_state, PATCH_PORT);
|
|
|
|
common::mainloop::mainloop(patch_state, patch_config.port);
|
|
|
|
|
|
|
|
println!("[patch] exiting...");
|
|
|
|
}
|