System Extensions is a cross-platform rust library that adds in additional functionality to manage opeartions of the operating system. System Extensions is split up into several modules that contain different functionality.
Modules - Processes - Metadata
The processes module gives functionality to detect processes running on the operating system.
rust
use system_extensions::processes::processes::find_process_id;
fn main() {
let result = find_process_id("Discord.exe");
println!("Program Id: {:?}", result.unwrap());
}
Note: Currently only implemented for Windows.
This module allows you to modify the metadata of a file.
You can change the creation, modified, and changed dates. ```rust use std::path::Path; use systemextensions::metadata::time::{FileTime, setcreation_date};
fn main() { setcreationdate(Path::new("C:\my_file.txt"), &FileTime::new(25, 12, 2021)); } ```
You can also set the attributes of a file. ```rust use std::path::Path; use systemextensions::metadata::attribute::{Attributes, setattribute};
fn main(){
setattribute(Path::new("C:\myfile.txt"), Attribute::HIDDEN);
}
Or check to see if a file has an attribute:
rust
use std::path::Path;
use systemextensions::metadata::attribute::{Attributes, hasattribute};
fn main(){ let value: bool = hasattribute(Path::new("C:\myfile.txt"), Attribute::HIDDEN); } ```