Last active
October 8, 2020 14:39
-
-
Save LordMZTE/543ee3ee9a343b1e8e83cd04b8ff16b9 to your computer and use it in GitHub Desktop.
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::File; | |
use std::path::Path; | |
/// opens a file from the resources folder | |
/// takes an `AsRef<Path>` for convenience. with this, a `&str` can be used | |
fn get_resource(path: impl AsRef<Path>) -> Option<File> { | |
let mut path_buf = std::env::current_exe().ok()?.parent()?.to_path_buf(); | |
path_buf.push("resources"); | |
path_buf.push(path); | |
File::open(path_buf).ok() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment