mirror of
https://github.com/posborne/rust-pstree.git
synced 2025-01-13 07:46:22 +01:00
rustup: use only stable features of the language
Previously std::path::PathExt was used but this is unstable and duplicates functionality in std::fs::metadata. Just use the stable functionality to support all versions of rust.1 Signed-off-by: Paul Osborne <osbpau@gmail.com>
This commit is contained in:
parent
fe0ed22080
commit
84a04e5dcd
1 changed files with 3 additions and 5 deletions
|
@ -27,8 +27,6 @@
|
||||||
// of different items, notably the process name and its parent process id (ppid).
|
// of different items, notably the process name and its parent process id (ppid).
|
||||||
// And with that information, we can build the process tree.
|
// And with that information, we can build the process tree.
|
||||||
|
|
||||||
#![feature(path_ext)]
|
|
||||||
|
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::io::prelude::*;
|
use std::io::prelude::*;
|
||||||
|
@ -108,10 +106,10 @@ fn get_process_records() -> Vec<ProcessRecord> {
|
||||||
let proc_directory_contents = fs::read_dir(&proc_directory).unwrap();
|
let proc_directory_contents = fs::read_dir(&proc_directory).unwrap();
|
||||||
proc_directory_contents.filter_map(|entry| {
|
proc_directory_contents.filter_map(|entry| {
|
||||||
let entry_path = entry.unwrap().path();
|
let entry_path = entry.unwrap().path();
|
||||||
if entry_path.is_dir() {
|
if fs::metadata(entry_path.as_path()).unwrap().is_dir() {
|
||||||
let status_path = entry_path.join("status");
|
let status_path = entry_path.join("status");
|
||||||
if status_path.exists() {
|
if fs::metadata(status_path.as_path()).unwrap().is_file() {
|
||||||
return get_process_record(&status_path)
|
return get_process_record(status_path.as_path())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None
|
None
|
||||||
|
|
Loading…
Reference in a new issue