dxm_init/lib.rs
1//! A crate for initializing FXServer data directories.
2
3use std::{error::Error, path::Path};
4
5use dxm_manifest::Manifest;
6use vcs::VcsOption;
7
8pub mod vcs;
9
10/// Initialize server data files in the given directory path with the given vcs.
11pub fn server<P>(path: P, vcs: &VcsOption) -> Result<(), Box<dyn Error>>
12where
13 P: AsRef<Path>,
14{
15 let path = path.as_ref();
16
17 fs_err::create_dir_all(path)?;
18
19 Manifest::default().write(path)?;
20
21 fs_err::create_dir_all(path.join("data").join("resources"))?;
22 fs_err::write(path.join("data").join("server.cfg"), "")?;
23
24 vcs.init(path)?;
25
26 Ok(())
27}