mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Fix a few more translation bugs
This commit is contained in:
+13
-3
@@ -29,9 +29,9 @@ pub fn find_associated_archives(
|
||||
// basename.
|
||||
GameType::TES4 => {
|
||||
if has_ascii_extension(plugin_path, "esp") {
|
||||
Vec::new()
|
||||
} else {
|
||||
find_associated_archives_with_arbitrary_suffixes(plugin_path, game_cache)
|
||||
} else {
|
||||
Vec::new()
|
||||
}
|
||||
},
|
||||
|
||||
@@ -92,6 +92,10 @@ fn find_associated_archives_with_arbitrary_suffixes(
|
||||
Some(s) => s.len(),
|
||||
None => return Vec::new(),
|
||||
};
|
||||
let plugin_extension = match plugin_path.extension() {
|
||||
Some(e) => e,
|
||||
None => return Vec::new(),
|
||||
};
|
||||
|
||||
game_cache
|
||||
.archives()
|
||||
@@ -106,13 +110,19 @@ fn find_associated_archives_with_arbitrary_suffixes(
|
||||
};
|
||||
|
||||
// Can't just slice the archive filename to the same length as the plugin file stem directly because that might not slice on a character boundary, so truncate the byte slice and then check it's still valid UTF-8.
|
||||
if archive_filename.len() < plugin_stem_len {
|
||||
return false;
|
||||
}
|
||||
|
||||
let filename =
|
||||
match std::str::from_utf8(&archive_filename.as_bytes()[..plugin_stem_len]) {
|
||||
Ok(f) => f,
|
||||
Err(_) => return false,
|
||||
};
|
||||
|
||||
let archive_plugin_path = plugin_path.with_file_name(filename);
|
||||
let archive_plugin_path = plugin_path
|
||||
.with_file_name(filename)
|
||||
.with_extension(plugin_extension);
|
||||
|
||||
are_file_paths_equivalent(&archive_plugin_path, plugin_path)
|
||||
})
|
||||
|
||||
+3
-2
@@ -85,7 +85,7 @@ impl Plugin {
|
||||
plugin_path: &Path,
|
||||
load_scope: LoadScope,
|
||||
) -> Result<Self, LoadPluginError> {
|
||||
let name = name_string(plugin_path)?;
|
||||
let name = name_string(game_type, plugin_path)?;
|
||||
|
||||
let (parse_options, crc) = if load_scope == LoadScope::HeaderOnly {
|
||||
(ParseOptions::header_only(), None)
|
||||
@@ -410,9 +410,10 @@ pub(crate) fn plugins_metadata(
|
||||
Ok(esplugin::plugins_metadata(&esplugins)?)
|
||||
}
|
||||
|
||||
fn name_string(path: &Path) -> Result<String, LoadPluginError> {
|
||||
fn name_string(game_type: GameType, path: &Path) -> Result<String, LoadPluginError> {
|
||||
match path.file_name() {
|
||||
Some(f) => match f.to_str() {
|
||||
Some(f) if game_type == GameType::OpenMW => Ok(f.to_string()),
|
||||
Some(f) => Ok(trim_dot_ghost(f).to_string()),
|
||||
None => Err(LoadPluginError::InvalidFilename(
|
||||
InvalidFilenameReason::NonUnicode,
|
||||
|
||||
Reference in New Issue
Block a user