fixed file write
This commit is contained in:
@@ -40,20 +40,17 @@ static GPIO_BTN_ON: &'static str = "0";
|
||||
static GPIO_LED_ON: &'static str = "0";
|
||||
static GPIO_LED_OFF: &'static str = "1";
|
||||
|
||||
fn open(path: &str) -> File {
|
||||
return File::open(Path::new(path))
|
||||
.expect(format!("Open file '{}' failed", path).as_str());
|
||||
}
|
||||
|
||||
fn write(path: &str, value: &str) {
|
||||
let mut file = open(path);
|
||||
let mut file = File::create(Path::new(path))
|
||||
.expect(format!("Open file '{}' failed", path).as_str());
|
||||
|
||||
file.write_all(value.as_bytes())
|
||||
.expect(format!("Write value '{}' to '{}' file failed", value, path).as_str());
|
||||
}
|
||||
|
||||
fn read(path: &str) -> String {
|
||||
let mut file = open(path);
|
||||
let mut file = File::open(Path::new(path))
|
||||
.expect(format!("Open file '{}' failed", path).as_str());
|
||||
let mut contents = String::new();
|
||||
|
||||
file.read_to_string(&mut contents)
|
||||
|
||||
Reference in New Issue
Block a user