1
0
Fork 0
mirror of synced 2024-06-26 18:11:04 +12:00

El capone

This commit is contained in:
Rafał Mikrut 2023-10-15 11:47:12 +02:00
parent 0fe77edf64
commit 618774162a
2 changed files with 15 additions and 19 deletions

View file

@ -18,7 +18,6 @@ core_folder_no_modification_date = Unable to get modification date from folder {
core_missing_no_chosen_included_directory = At least one directory must be provided
core_directory_wildcard_no_supported = Directories: Wildcards in path are not supported, ignoring { $path }
core_directory_relative_path = Directories: Relative path are not supported, ignoring { $path }
core_directory_must_exists = Directories: Provided folder path must exist, ignoring { $path }
core_directory_must_be_directory = Directories: Provided path must point at the directory, ignoring { $path }
core_included_directory_zero_valid_directories = Included Directory ERROR: Not found even one correct path to included which is required

View file

@ -61,10 +61,13 @@ impl Directories {
continue;
}
// If not checking windows strange paths, try to canonicalize them
// Try to canonicalize them
if let Ok(dir) = directory.canonicalize() {
directory = dir;
}
if cfg!(linux) {
directory = PathBuf::from(directory.strip_prefix(r"\\?\").unwrap_or(&directory));
}
checked_directories.push(directory);
}
@ -89,7 +92,7 @@ impl Directories {
let directories: Vec<PathBuf> = excluded_directory;
let mut checked_directories: Vec<PathBuf> = Vec::new();
for directory in directories {
for mut directory in directories {
let directory_as_string = directory.to_string_lossy();
if directory_as_string == "/" {
messages.errors.push(flc!("core_excluded_directory_pointless_slash"));
@ -102,27 +105,12 @@ impl Directories {
));
continue;
}
#[cfg(not(target_family = "windows"))]
if directory.is_relative() {
messages.warnings.push(flc!(
"core_directory_relative_path",
generate_translation_hashmap(vec![("path", directory.display().to_string())])
));
continue;
}
#[cfg(target_family = "windows")]
if directory.is_relative() && !directory.starts_with("\\") {
messages.warnings.push(flc!(
"core_directory_relative_path",
generate_translation_hashmap(vec![("path", directory.display().to_string())])
));
continue;
}
if !directory.exists() {
// No error when excluded directories are missing
continue;
}
if !directory.is_dir() {
messages.warnings.push(flc!(
"core_directory_must_be_directory",
@ -130,6 +118,15 @@ impl Directories {
));
continue;
}
// Try to canonicalize them
if let Ok(dir) = directory.canonicalize() {
directory = dir;
}
if cfg!(linux) {
directory = PathBuf::from(directory.strip_prefix(r"\\?\").unwrap_or(&directory));
}
checked_directories.push(directory);
}
self.excluded_directories = checked_directories;