More consistent handling of non-Unicode file names (should be rare)

This commit is contained in:
Lucien Greathouse
2019-10-09 17:15:34 -07:00
parent dca88e8272
commit dfabc07044
4 changed files with 46 additions and 11 deletions

View File

@@ -7,7 +7,10 @@ use crate::{
snapshot::InstanceSnapshot,
};
use super::middleware::{SnapshotFileResult, SnapshotInstanceResult, SnapshotMiddleware};
use super::{
error::SnapshotError,
middleware::{SnapshotFileResult, SnapshotInstanceResult, SnapshotMiddleware},
};
pub struct SnapshotRbxmx;
@@ -20,7 +23,12 @@ impl SnapshotMiddleware for SnapshotRbxmx {
return Ok(None);
}
let file_name = entry.path().file_name().unwrap().to_string_lossy();
let file_name = entry
.path()
.file_name()
.unwrap()
.to_str()
.ok_or_else(|| SnapshotError::file_name_bad_unicode(entry.path()))?;
if !file_name.ends_with(".rbxmx") {
return Ok(None);
@@ -30,7 +38,8 @@ impl SnapshotMiddleware for SnapshotRbxmx {
.path()
.file_stem()
.expect("Could not extract file stem")
.to_string_lossy()
.to_str()
.ok_or_else(|| SnapshotError::file_name_bad_unicode(entry.path()))?
.to_string();
let options = rbx_xml::DecodeOptions::new()