1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
use std::path::{Path, PathBuf};
use anyhow::{ensure, Result};
#[derive(Debug, thiserror::Error)]
pub enum BuildError {
#[error("Missing required directory: '{0}'.")]
MissingFolderError(&'static str),
#[error("Missing required file: '{0}'.")]
MissingFileError(&'static str),
}
#[derive(Clone, Debug, Default, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct Builder {
root: PathBuf,
}
impl Builder {
pub fn new<P: AsRef<Path>>(path: P) -> Result<Self> {
let root = path.as_ref();
Ok(Self {
root: root.to_path_buf(),
})
}
pub fn is_nds_dir<P: AsRef<Path>>(path: P) -> Result<()> {
let root = path.as_ref();
ensure!(root.is_dir(), BuildError::MissingFolderError("root"));
ensure!(
root.join("data").is_dir(),
BuildError::MissingFolderError("data")
);
ensure!(
root.join("overlay").is_dir(),
BuildError::MissingFolderError("overlay")
);
ensure!(
root.join("arm9_overlay.bin").is_file(),
BuildError::MissingFileError("arm9_overlay.bin")
);
ensure!(
root.join("arm7_overlay.bin").is_file(),
BuildError::MissingFileError("arm7_overlay.bin")
);
ensure!(
root.join("arm9.bin").is_file(),
BuildError::MissingFileError("arm9.bin")
);
ensure!(
root.join("arm7.bin").is_file(),
BuildError::MissingFileError("arm7.bin")
);
ensure!(
root.join("header.bin").is_file(),
BuildError::MissingFileError("header.bin")
);
Ok(())
}
pub fn build<P: AsRef<Path>>(&self, path: P) -> Result<()> {
let _output = path.as_ref();
Ok(())
}
}