mirror of https://github.com/AlexeyAB/darknet.git
Support label image filename with multiple extension. (#6667)
This commit is contained in:
parent
2f4ab0887c
commit
82eb049fdc
13
src/utils.c
13
src/utils.c
|
@ -240,12 +240,23 @@ void trim(char *str)
|
|||
free(buffer);
|
||||
}
|
||||
|
||||
char *strlaststr(char *haystack, char *needle)
|
||||
{
|
||||
char *p = strstr(haystack, needle), *r = NULL;
|
||||
while (p != NULL)
|
||||
{
|
||||
r = p;
|
||||
p = strstr(p + 1, needle);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
void find_replace_extension(char *str, char *orig, char *rep, char *output)
|
||||
{
|
||||
char* buffer = (char*)calloc(8192, sizeof(char));
|
||||
|
||||
sprintf(buffer, "%s", str);
|
||||
char *p = strstr(buffer, orig);
|
||||
char *p = strlaststr(buffer, orig);
|
||||
int offset = (p - buffer);
|
||||
int chars_from_end = strlen(buffer) - offset;
|
||||
if (!p || chars_from_end != strlen(orig)) { // Is 'orig' even in 'str' AND is 'orig' found at the end of 'str'?
|
||||
|
|
Loading…
Reference in New Issue