1
0
Fork 0
mirror of https://github.com/DarkMatterCore/nxdumptool.git synced 2024-11-29 21:52:22 +00:00

Tweaks to utilsReplaceIllegalCharacters.

We won't need to replace characters outside of the ASCII range for USB transfers.
This commit is contained in:
Pablo Curiel 2020-05-05 14:04:23 -04:00
parent 298676ae46
commit 253e72786b
2 changed files with 3 additions and 14 deletions

View file

@ -245,18 +245,7 @@ out:
mutexUnlock(&g_logfileMutex); mutexUnlock(&g_logfileMutex);
} }
void removeIllegalCharacters(char *name) void utilsReplaceIllegalCharacters(char *str, bool ascii_only)
{
if (!name || !strlen(name)) return;
u32 i, len = strlen(name);
for (i = 0; i < len; i++)
{
if (memchr("?[]/\\=+<>:;\",*|^", name[i], sizeof("?[]/\\=+<>:;\",*|^") - 1) || name[i] < 0x20 || name[i] > 0x7E) name[i] = '_';
}
}
void utilsReplaceIllegalCharacters(char *str)
{ {
size_t strsize = 0; size_t strsize = 0;
@ -264,7 +253,7 @@ void utilsReplaceIllegalCharacters(char *str)
for(size_t i = 0; i < strsize; i++) for(size_t i = 0; i < strsize; i++)
{ {
if (memchr("?[]/\\=+<>:;\",*|^", str[i], sizeof("?[]/\\=+<>:;\",*|^") - 1) || str[i] < 0x20 || str[i] > 0x7E) str[i] = '_'; if (memchr("?[]/\\=+<>:;\",*|^", str[i], sizeof("?[]/\\=+<>:;\",*|^") - 1) || str[i] < 0x20 || (!ascii_only && str[i] == 0x7F) || (ascii_only && str[i] >= 0x7F)) str[i] = '_';
} }
} }

View file

@ -67,7 +67,7 @@ void utilsWaitForButtonPress(void);
void utilsWriteLogMessage(const char *func_name, const char *fmt, ...); void utilsWriteLogMessage(const char *func_name, const char *fmt, ...);
void utilsReplaceIllegalCharacters(char *str); void utilsReplaceIllegalCharacters(char *str, bool ascii_only);
void utilsTrimString(char *str); void utilsTrimString(char *str);