Browse Source

initial commit

master
Jared Dunbar 3 years ago
commit
5fec250bcb
Signed by: jared GPG Key ID: CF202CC859BAC692
  1. 2
      .gitignore
  2. 4
      Cargo.lock
  3. 11
      Cargo.toml
  4. 36
      src/lib.rs
  5. 20
      src/main.rs

2
.gitignore

@ -0,0 +1,2 @@
/target
**/*.rs.bk

4
Cargo.lock

@ -0,0 +1,4 @@
[[package]]
name = "mc_lang"
version = "0.1.0"

11
Cargo.toml

@ -0,0 +1,11 @@
[package]
name = "mc_lang"
version = "0.1.0"
authors = ["Jared Dunbar <jrddunbr@gmail.com>"]
edition = "2018"
[lib]
name = "mc_lang"
path = "src/lib.rs"
[dependencies]

36
src/lib.rs

@ -0,0 +1,36 @@
use std::io;
use std::io::Read;
use std::fs::File;
pub fn read_file(filename: &str) -> Result<String, std::io::Error> {
// get the first filename
let mut en_us_lang_file = String::new();
let mut en_us_lang = String::new();
println!("Please specify the location of the {} file:", &filename);
match io::stdin().read_line(&mut en_us_lang_file) {
Ok(_) => (),
Err(e) => return Err(e),
};
let en_us_lang_file = en_us_lang_file.trim();
let f = File::open(&en_us_lang_file);
let mut f = match f {
Ok(file) => file,
Err(e) => {
println!("There was an error opening the file.");
return Err(e);
},
};
match f.read_to_string(&mut en_us_lang) {
Ok(_) => (),
Err(e) => {
println!("There was an error reading the file.");
return Err(e);
},
};
Ok(en_us_lang)
}

20
src/main.rs

@ -0,0 +1,20 @@
use mc_lang;
fn main() {
println!("Welcome to the Minecraft language file parsing utility.");
let mut en_us_lang = String::new();
loop {
// get the canonical file
en_us_lang = match mc_lang::read_file("en_US.lang") {
Ok(contents) => {
contents
},
Err(_) => continue,
};
break;
}
println!("{}", en_us_lang);
}
Loading…
Cancel
Save