Skip to content

Commit

Permalink
refactor(util)!: rename open_dir() to open_dir_following_links()
Browse files Browse the repository at this point in the history
  • Loading branch information
rami3l committed Mar 31, 2024
1 parent 04f1bd8 commit eb75cdf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/toolchain/toolchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use crate::{
currentprocess::{process, varsource::VarSource},
env_var, install,
notifications::Notification,
utils::{raw::open_dir, utils},
utils::{raw::open_dir_following_links, utils},
RustupError,
};

Expand Down Expand Up @@ -62,7 +62,7 @@ impl<'a> Toolchain<'a> {
let base_name = path
.file_name()
.ok_or_else(|| RustupError::InvalidToolchainName(name.to_string()))?;
let parent_dir = match open_dir(parent) {
let parent_dir = match open_dir_following_links(parent) {
Ok(d) => d,
Err(e) if e.kind() == io::ErrorKind::NotFound => return Ok(false),
e => e?,
Expand Down
5 changes: 3 additions & 2 deletions src/utils/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub fn is_file<P: AsRef<Path>>(path: P) -> bool {
}

#[cfg(windows)]
pub fn open_dir(p: &Path) -> std::io::Result<File> {
pub fn open_dir_following_links(p: &Path) -> std::io::Result<File> {
use std::fs::OpenOptions;
use std::os::windows::fs::OpenOptionsExt;

Expand All @@ -42,8 +42,9 @@ pub fn open_dir(p: &Path) -> std::io::Result<File> {
options.custom_flags(FILE_FLAG_BACKUP_SEMANTICS);
options.open(p)
}

#[cfg(not(windows))]
pub fn open_dir(p: &Path) -> std::io::Result<File> {
pub fn open_dir_following_links(p: &Path) -> std::io::Result<File> {
use std::fs::OpenOptions;

let mut options = OpenOptions::new();
Expand Down

0 comments on commit eb75cdf

Please sign in to comment.