ArchiveLookup: move code to FindSuffix()
This commit is contained in:
parent
1b8a1d4140
commit
fd9dd9343b
@ -29,6 +29,18 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
gcc_pure
|
||||||
|
static const char *
|
||||||
|
FindSuffix(const char *p, size_t i)
|
||||||
|
{
|
||||||
|
for (; i > 0; --i) {
|
||||||
|
if (p[i] == '.')
|
||||||
|
return p + i + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
archive_lookup(char *pathname, const char **archive,
|
archive_lookup(char *pathname, const char **archive,
|
||||||
const char **inpath, const char **suffix)
|
const char **inpath, const char **suffix)
|
||||||
@ -67,14 +79,7 @@ archive_lookup(char *pathname, const char **archive,
|
|||||||
*inpath = pathname + idx+1;
|
*inpath = pathname + idx+1;
|
||||||
|
|
||||||
//try to get suffix
|
//try to get suffix
|
||||||
*suffix = NULL;
|
*suffix = FindSuffix(pathname, idx);
|
||||||
while (idx > 0) {
|
|
||||||
if (pathname[idx] == '.') {
|
|
||||||
*suffix = pathname + idx + 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
idx--;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
FormatError(archive_domain,
|
FormatError(archive_domain,
|
||||||
|
Loading…
Reference in New Issue
Block a user