Create CD desc

This commit is contained in:
Jaby 2022-10-06 21:23:40 +02:00 committed by Jaby
parent 5537434db1
commit 2a9dcb611c
1 changed files with 5 additions and 3 deletions

View File

@ -47,8 +47,9 @@ pub struct DirectoryName {
} }
impl DirectoryName { impl DirectoryName {
pub fn from_str(str: &str) -> Result<DirectoryName, Error> { pub fn from_str(dir_name: &str) -> Result<DirectoryName, Error> {
Ok(DirectoryName{name: DString::from_str(str)?}) let dir_name = dir_name.to_uppercase();
Ok(DirectoryName{name: DString::from_str(dir_name.as_ref())?})
} }
} }
@ -59,6 +60,7 @@ pub struct FileName {
impl FileName { impl FileName {
pub fn from_str(file_name: &str) -> Result<FileName, Error> { pub fn from_str(file_name: &str) -> Result<FileName, Error> {
let file_name = file_name.to_uppercase();
let (name, ext) = { let (name, ext) = {
let mut sub_str = file_name.split('.'); let mut sub_str = file_name.split('.');
(Error::ok_or_new(sub_str.next(), || "File name can't be emplty".to_owned())?, sub_str.next()) (Error::ok_or_new(sub_str.next(), || "File name can't be emplty".to_owned())?, sub_str.next())