You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.3 KiB
39 lines
1.3 KiB
#![feature(const_generics)]
|
|
|
|
mod common;
|
|
mod patch;
|
|
use crate::patch::patch::{PatchServerState, PatchTreeIterItem, generate_patch_tree, PATCH_PORT};
|
|
|
|
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_file_tree, patch_file_lookup) = generate_patch_tree("patchfiles/");
|
|
println!("[patch] files to patch:");
|
|
let mut indent = 0;
|
|
for item in patch_file_tree.flatten() {
|
|
match item {
|
|
PatchTreeIterItem::Directory(path) => {
|
|
let s = path.to_str().unwrap();
|
|
println!("{: >2$}\u{2517}\u{2500}\u{2500} {}", "", s, indent * 4);
|
|
indent += 1;
|
|
},
|
|
PatchTreeIterItem::File(path, id) => {
|
|
let s = path.to_str().unwrap();
|
|
println!("{: >3$}\u{2520}\u{2500}\u{2500} {} ({})", "", s, id, indent * 4);
|
|
},
|
|
PatchTreeIterItem::UpDirectory => {
|
|
indent -= 1;
|
|
}
|
|
}
|
|
}
|
|
|
|
let patch_state = PatchServerState::new(patch_file_tree, patch_file_lookup);
|
|
common::mainloop::mainloop(patch_state, PATCH_PORT);
|
|
|
|
println!("[patch] exiting...");
|
|
}
|