simplify file name sanitization #399

Merged
stklcode merged 1 commits from fix/cleanup-filename into master 2022-12-21 02:14:16 -06:00
stklcode commented 2022-12-21 02:12:57 -06:00 (Migrated from github.com)

Description

The routine copies fileNameLen characters from the original filename plus one additional character or a trailing blank. This additional char is overwritten by a terminating null-byte afterwards anyway.

Remove the redundant check and simplify the loop.

Also only truncate the filename, if the actual length is greater than the limit.
With >= MAX_PRINTABLE_FILENAME_LEN we would remove the last character of a valid file name, e.g. 0123456789abcdefghij.gcode would be printed as 0123456789abcdefghi~.gcode

Requirements

Applies to targets with DGUS-clone display.

Benefits

Cleaner and faster code. No truncation for 26 character filenames.

Configurations

--

closes #393

Discussed and tested with @leonel85 in https://github.com/knutwurst/Marlin-2-0-x-Anycubic-i3-MEGA-S/issues/393#issuecomment-1360881584

### Description The routine copies `fileNameLen` characters from the original filename plus one additional character or a trailing blank. This additional char is overwritten by a terminating null-byte afterwards anyway. Remove the redundant check and simplify the loop. Also only truncate the filename, if the actual length is greater than the limit. With `>= MAX_PRINTABLE_FILENAME_LEN` we would remove the last character of a valid file name, e.g. `0123456789abcdefghij.gcode` would be printed as `0123456789abcdefghi~.gcode` ### Requirements Applies to targets with DGUS-clone display. ### Benefits Cleaner and faster code. No truncation for 26 character filenames. ### Configurations -- ### Related Issues closes #393 Discussed and tested with @leonel85 in https://github.com/knutwurst/Marlin-2-0-x-Anycubic-i3-MEGA-S/issues/393#issuecomment-1360881584
Sign in to join this conversation.
No description provided.