Skip to content
Myr

Use .canonicalize() to check paths & Reword comments

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by J.W · committed by David Peter · parent e649c8f · Browse files · 1 file+4 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+4 added−3 removed

  • other:+4 added−3 removed

1 file+4 added−3 removed

modified:src/main.rs+4 added-3 removed
34 unmodified lines
35 let pattern = matches.value_of("pattern").unwrap_or(&empty_pattern);3637 // Get the current working directory38 let current_dir = Path::new(".");39 if !current_dir.is_dir() {39 // .is_dir() is not guarandteed to be intuitively correct for "." and ".."40 if let Err(_) = current_dir.canonicalize() {41 error("Error: could not get current directory.");42 }4344 // Get the root directory for the search45 let mut root_dir_buf = match matches.value_of("path") {46 Some(path) => PathBuf::from(path),47 None => current_dir.to_path_buf(),48 };48 if !root_dir_buf.is_dir() {49 if let Err(_) = root_dir_buf.canonicalize() {50 error(&format!(51 "Error: '{}' is not a directory.",52 root_dir_buf.to_string_lossy()53 ));
71 unmodified lines
125126 // If base_dir is ROOT_DIR, then root_dir must be absolute.127 // Otherwise root_dir/entry cannot be turned into an existing relative path from base_dir.128 //128 // We utilize ROOT_DIR to avoid resolving parent directories the root_dir.129 // We utilize ROOT_DIR to avoid resolving the components of root_dir.130 let base_dir_buf = match config.path_display {131 PathDisplay::Relative => current_dir.to_path_buf(),132 PathDisplay::Absolute => PathBuf::from(ROOT_DIR),133 };
10 unmodified lines