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.
Add this to your Cargo.toml
file to use it.
toml
system-extensions = {version = "0.0.2", features = ["metadata", "processes"]}
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());
}
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("./my_file.txt"), &FileTime::new(25, 12, 2021)); } ```
Note: Currently only implemented for windows.
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("./myfile.txt"), Attributes::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("./myfile.txt"), Attributes::HIDDEN); } ```