mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-30 11:21:15 -03:00
path: de-duplicate getter logic
Also remove comments which were already obsolete before these changes. Closes #12365
This commit is contained in:
committed by
Johannes Altmanninger
parent
77471c500e
commit
28c0a8bc81
34
src/path.rs
34
src/path.rs
@@ -18,32 +18,16 @@
|
|||||||
|
|
||||||
/// Returns the user configuration directory for fish. If the directory or one of its parents
|
/// Returns the user configuration directory for fish. If the directory or one of its parents
|
||||||
/// doesn't exist, they are first created.
|
/// doesn't exist, they are first created.
|
||||||
///
|
|
||||||
/// \param path The directory as an out param
|
|
||||||
/// Return whether the directory was returned successfully
|
|
||||||
pub fn path_get_config() -> Option<WString> {
|
pub fn path_get_config() -> Option<WString> {
|
||||||
let dir = get_config_directory();
|
get_config_directory().path()
|
||||||
if dir.success() {
|
|
||||||
Some(dir.path.clone())
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the user data directory for fish. If the directory or one of its parents doesn't exist,
|
/// Returns the user data directory for fish. If the directory or one of its parents doesn't exist,
|
||||||
/// they are first created.
|
/// they are first created.
|
||||||
///
|
///
|
||||||
/// Volatile files presumed to be local to the machine, such as the fish_history will be stored in this directory.
|
/// Volatile files presumed to be local to the machine, such as the fish_history will be stored in this directory.
|
||||||
///
|
|
||||||
/// \param path The directory as an out param
|
|
||||||
/// Return whether the directory was returned successfully
|
|
||||||
pub fn path_get_data() -> Option<WString> {
|
pub fn path_get_data() -> Option<WString> {
|
||||||
let dir = get_data_directory();
|
get_data_directory().path()
|
||||||
if dir.success() {
|
|
||||||
Some(dir.path.clone())
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the user cache directory for fish. If the directory or one of its parents doesn't exist,
|
/// Returns the user cache directory for fish. If the directory or one of its parents doesn't exist,
|
||||||
@@ -51,16 +35,8 @@ pub fn path_get_data() -> Option<WString> {
|
|||||||
///
|
///
|
||||||
/// Volatile files presumed to be local to the machine such as all the
|
/// Volatile files presumed to be local to the machine such as all the
|
||||||
/// generated_completions, will be stored in this directory.
|
/// generated_completions, will be stored in this directory.
|
||||||
///
|
|
||||||
/// \param path The directory as an out param
|
|
||||||
/// Return whether the directory was returned successfully
|
|
||||||
pub fn path_get_cache() -> Option<WString> {
|
pub fn path_get_cache() -> Option<WString> {
|
||||||
let dir = get_cache_directory();
|
get_cache_directory().path()
|
||||||
if dir.success() {
|
|
||||||
Some(dir.path.clone())
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Eq, PartialEq)]
|
#[derive(Clone, Copy, Eq, PartialEq)]
|
||||||
@@ -568,8 +544,8 @@ struct BaseDirectory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl BaseDirectory {
|
impl BaseDirectory {
|
||||||
fn success(&self) -> bool {
|
fn path(&self) -> Option<WString> {
|
||||||
self.err.is_none()
|
self.err.is_none().then(|| self.path.clone())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user