changeset 21:229a4f04038c

Fix critical bug in procfs parsers (helper.rs)
author Lewin Bormann <lbo@spheniscida.de>
date Sun, 14 Feb 2016 17:54:13 +0100
parents d69c429b176c
children 83f8cbf8cc58
files src/helper.rs
diffstat 1 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/helper.rs	Sun Feb 14 17:53:51 2016 +0100
+++ b/src/helper.rs	Sun Feb 14 17:54:13 2016 +0100
@@ -14,7 +14,7 @@
     let mut fullpath = String::from("/proc/");
     fullpath.push_str(&path);
 
-    match fs::OpenOptions::new().read(true).open(path) {
+    match fs::OpenOptions::new().read(true).open(fullpath) {
         Err(_) => return None,
         Ok(f) => file = f,
     }
@@ -34,6 +34,10 @@
 pub fn get_procfs_file_lines(path: String) -> Option<Vec<String>> {
     match read_procfs_file(path) {
         None => None,
-        Some(s) => Some(s.lines().map(|s| String::from(s)).collect()),
+        Some(s) => Some(s.lines().map(String::from).collect()),
     }
 }
+
+pub fn commaseparated_to_vec(s: String) -> Vec<String> {
+    s.split(",").map(String::from).collect()
+}