diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-02-27 06:18:30 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-02-27 06:18:30 +0800 |
| commit | da1a67d4d32b081fee59f30c43695de21225522a (patch) | |
| tree | 84cdb00e05f4d85f9e441894f846cfaa1b884bd0 /utils/src/env.rs | |
| parent | 49f8161fafb636d9d44d2f0878a7429058fb1db6 (diff) | |
Add utility functions and macros
- Add `current_tempfile_path` function to get temporary file paths
- Add `input_with_editor_custom` function that accepts custom editor
- Add `string_vec!` macro for creating `Vec<String>` from literals
Diffstat (limited to 'utils/src/env.rs')
| -rw-r--r-- | utils/src/env.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/utils/src/env.rs b/utils/src/env.rs index 81dfbd7..1834cd3 100644 --- a/utils/src/env.rs +++ b/utils/src/env.rs @@ -1,3 +1,5 @@ +use std::path::PathBuf; + /// Returns the current locale string based on environment variables. /// /// The function checks for locale settings in the following order: @@ -92,3 +94,14 @@ pub async fn get_default_editor() -> String { "jvii".to_string() } + +/// Get temporary file path +pub fn current_tempfile_path(name: &str) -> Option<PathBuf> { + dirs::config_local_dir().map(|path| { + if cfg!(target_os = "linux") { + path.join("jvcs").join(".temp").join(name) + } else { + path.join("JustEnoughVCS").join(".temp").join(name) + } + }) +} |
