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

6 years ago
  1. #![feature(const_generics)]
  2. mod common;
  3. mod patch;
  4. use crate::patch::patch::{PatchServerState, PatchTreeIterItem, generate_patch_tree, PATCH_PORT};
  5. fn main() {
  6. println!("[patch] starting server");
  7. if let Err(_) = std::fs::read_dir("patchfiles/") {
  8. if let Err(_) = std::fs::create_dir("patchfiles/") {
  9. panic!("Could not create patchfiles directory!");
  10. }
  11. }
  12. let (patch_file_tree, patch_file_lookup) = generate_patch_tree("patchfiles/");
  13. println!("[patch] files to patch:");
  14. let mut indent = 0;
  15. for item in patch_file_tree.flatten() {
  16. match item {
  17. PatchTreeIterItem::Directory(path) => {
  18. let s = path.to_str().unwrap();
  19. println!("{: >2$}\u{2517}\u{2500}\u{2500} {}", "", s, indent * 4);
  20. indent += 1;
  21. },
  22. PatchTreeIterItem::File(path, id) => {
  23. let s = path.to_str().unwrap();
  24. println!("{: >3$}\u{2520}\u{2500}\u{2500} {} ({})", "", s, id, indent * 4);
  25. },
  26. PatchTreeIterItem::UpDirectory => {
  27. indent -= 1;
  28. }
  29. }
  30. }
  31. let patch_state = PatchServerState::new(patch_file_tree, patch_file_lookup);
  32. common::mainloop::mainloop(patch_state, PATCH_PORT);
  33. println!("[patch] exiting...");
  34. }