Created
December 30, 2019 14:53
-
-
Save geekswamp/efe26fa29b43670f0bcd222566d4023f to your computer and use it in GitHub Desktop.
Listing file & folder with Rust
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[package] | |
name = "sysinfo" | |
version = "0.1.0" | |
authors = ["Ahmad Rifa'i <[email protected]>"] | |
edition = "2018" | |
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | |
[dependencies] | |
# sys-info = "*" | |
whoami = "0.6.0" | |
serde_json = "1.0" | |
serde = { version = "1.0", features = ["derive"] } | |
reqwest = "0.9.24" | |
dirs = "2.0.2" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::fs; | |
use std::path::PathBuf; | |
extern crate dirs; | |
fn main() { | |
let home = dirs::home_dir().unwrap(); | |
let home2 = home.into_os_string().into_string().unwrap(); | |
let from_path: PathBuf = ["{}", &home2, "Documents"].iter().collect(); | |
let _display = from_path.display(); | |
println!("From path: {}", _display); | |
let paths = fs::read_dir(&from_path).unwrap(); | |
for path in paths { | |
println!("List: {}", path.unwrap().path().display()) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment