Support extensionless in swap_extension

This commit is contained in:
NicknineTheEagle 2023-08-22 15:00:20 +03:00
parent 474c15723a
commit c58b1650c9

View File

@ -9,11 +9,18 @@ static void swap_extension(char* pathname, /*size_t*/ int pathname_len, const ch
char* extension = (char*)filename_extension(pathname);
//todo safeops
if (extension[0] == '\0') {
if (swap[0] != '\0') {
strcat(pathname, ".");
strcat(pathname, swap);
}
}
else {
if (swap[0] != '\0') {
strcpy(extension, swap);
} else {
extension--;
extension[0] = '\0';
}
}
}