Module structure
This commit is contained in:
@@ -8,10 +8,9 @@ pub class Module {
|
||||
pub PathBuf path;
|
||||
pub Vec<Self> children;
|
||||
|
||||
pub constructor(PathBuf mist_path) {
|
||||
pub constructor(String name, PathBuf mist_path, PathBuf rust_path) {
|
||||
self.children = new Vec();
|
||||
self.name = mist_path.file_stem()
|
||||
.and_then(|var s| s.to_str()).expect("Failed to get module name").to_string();
|
||||
self.name = name;
|
||||
self.path = mist_path;
|
||||
|
||||
if (self.path.is_dir()) {
|
||||
@@ -40,12 +39,32 @@ pub class Module {
|
||||
|
||||
PathBuf child_path = entry.path();
|
||||
|
||||
self.children.push(new Module(child_path));
|
||||
String child_name = child_path.file_stem()
|
||||
.and_then(|var s| s.to_str())
|
||||
.expect("Failed to get module name")
|
||||
.to_string();
|
||||
|
||||
PathBuf child_output = rust_path.join(&child_name).with_extension("rs");
|
||||
|
||||
if (should_skip(&child_path, &child_output)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
self.children.push(new Module(child_name, child_path, child_output));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub Module new_package(PathBuf mist_path, PathBuf rust_path) {
|
||||
String name = mist_path.file_stem()
|
||||
.and_then(|var s| s.to_str())
|
||||
.expect("Failed to get module name")
|
||||
.to_string();
|
||||
|
||||
new Module(name, mist_path, rust_path)
|
||||
}
|
||||
|
||||
bool should_skip(Path* source, Path* output) {
|
||||
var src_time = fs::metadata(source)
|
||||
.ok()
|
||||
|
||||
Reference in New Issue
Block a user