mirror of
https://github.com/crunchy-labs/crunchy-cli.git
synced 2026-01-21 04:02:00 -06:00
Automatically cut too long path segments
This commit is contained in:
parent
74aaed4e7a
commit
cf8bfb02ac
1 changed files with 27 additions and 1 deletions
|
|
@ -526,7 +526,33 @@ impl Format {
|
|||
),
|
||||
);
|
||||
|
||||
PathBuf::from(path)
|
||||
let mut path = PathBuf::from(path);
|
||||
|
||||
// make sure that every path section has a maximum of 255 characters
|
||||
if path.file_name().unwrap_or_default().to_string_lossy().len() > 255 {
|
||||
let name = path
|
||||
.file_stem()
|
||||
.unwrap_or_default()
|
||||
.to_string_lossy()
|
||||
.to_string();
|
||||
let ext = path
|
||||
.extension()
|
||||
.unwrap_or_default()
|
||||
.to_string_lossy()
|
||||
.to_string();
|
||||
if ext != name {
|
||||
path.set_file_name(format!("{}.{}", &name[..(255 - ext.len() - 1)], ext))
|
||||
}
|
||||
}
|
||||
path.into_iter()
|
||||
.map(|s| {
|
||||
if s.len() > 255 {
|
||||
s.to_string_lossy()[..255].to_string()
|
||||
} else {
|
||||
s.to_string_lossy().to_string()
|
||||
}
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub fn visual_output(&self, dst: &Path) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue