imported previous rust projects and cleaned up unused files
This commit is contained in:
parent
0166b32872
commit
10b8db251b
432 changed files with 874 additions and 1585 deletions
1
tempdir/rusttest/.gitignore
vendored
Normal file
1
tempdir/rusttest/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
/target
|
7
tempdir/rusttest/Cargo.lock
generated
Normal file
7
tempdir/rusttest/Cargo.lock
generated
Normal file
|
@ -0,0 +1,7 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "rusttest"
|
||||
version = "0.1.0"
|
8
tempdir/rusttest/Cargo.toml
Normal file
8
tempdir/rusttest/Cargo.toml
Normal file
|
@ -0,0 +1,8 @@
|
|||
[package]
|
||||
name = "rusttest"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
64
tempdir/rusttest/src/main.rs
Normal file
64
tempdir/rusttest/src/main.rs
Normal file
|
@ -0,0 +1,64 @@
|
|||
use std::fs;
|
||||
use std::time::Instant;
|
||||
|
||||
const PATH: &str = "/usr/share/applications/";
|
||||
|
||||
fn read(path: &str) -> std::io::Result<()> {
|
||||
let files = fs::read_dir(path)?;
|
||||
for file in files {
|
||||
let file = file?;
|
||||
let path = file.path();
|
||||
let extension = path.extension().expect("error");
|
||||
|
||||
if extension != "desktop" {
|
||||
continue;
|
||||
}
|
||||
|
||||
let mut class: &str = "";
|
||||
let mut name: &str = "";
|
||||
let mut icon: &str = "";
|
||||
|
||||
let file = fs::read_to_string(path)?;
|
||||
|
||||
for line in file.lines() {
|
||||
match line {
|
||||
line if line.starts_with("StartupWMClass") => {
|
||||
class = match line.split_once('=') {
|
||||
Some((_, class)) => class,
|
||||
None => "",
|
||||
}
|
||||
}
|
||||
line if line.starts_with("Name") => {
|
||||
name = match line.split_once('=') {
|
||||
Some((_, name)) => name,
|
||||
None => "",
|
||||
}
|
||||
}
|
||||
line if line.starts_with("Icon") => {
|
||||
icon = match line.split_once('=') {
|
||||
Some((_, icon)) => icon,
|
||||
None => "",
|
||||
}
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
println!("Class: {class}, Name: {name}, Icon: {icon}");
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let start_time = Instant::now();
|
||||
read(PATH).expect("error");
|
||||
let end_time = Instant::now();
|
||||
|
||||
let time = end_time - start_time;
|
||||
|
||||
println!(
|
||||
"Time taken: {}.{:03}s",
|
||||
time.as_secs(),
|
||||
time.subsec_millis()
|
||||
);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue