archive/ArchiveLookup: remove "suffix" output parameter

Let the caller do this.  Our GetSuffix() function was broken anyway.
This commit is contained in:
Max Kellermann
2019-05-31 19:01:22 +02:00
parent 508ba22789
commit 12e75a523a
4 changed files with 15 additions and 31 deletions

View File

@@ -36,21 +36,9 @@ FindSlash(char *p, size_t i) noexcept
return nullptr;
}
gcc_pure
static const char *
FindSuffix(const char *p, const char *i) noexcept
{
for (; i > p; --i) {
if (*i == '.')
return i + 1;
}
return nullptr;
}
bool
archive_lookup(char *pathname, const char **archive,
const char **inpath, const char **suffix)
const char **inpath)
{
size_t idx = strlen(pathname);
@@ -70,9 +58,6 @@ archive_lookup(char *pathname, const char **archive,
//so the upper should be file
*archive = pathname;
*inpath = slash + 1;
//try to get suffix
*suffix = FindSuffix(pathname, slash - 1);
return true;
} else {
FormatError(archive_domain,

View File

@@ -24,24 +24,23 @@
*
* archive_lookup is used to determine if part of pathname refers to an regular
* file (archive). If so then its also used to split pathname into archive file
* and path used to locate file in archive. It also returns suffix of the file.
* and path used to locate file in archive.
* How it works:
* We do stat of the parent of input pathname as long as we find an regular file
* Normally this should never happen. When routine returns true pathname modified
* and split into archive, inpath and suffix. Otherwise nothing happens
* and split into archive and inpath. Otherwise nothing happens
*
* For example:
*
* /music/path/Talco.zip/Talco - Combat Circus/12 - A la pachenka.mp3
* is split into archive: /music/path/Talco.zip
* inarchive pathname: Talco - Combat Circus/12 - A la pachenka.mp3
* and suffix: zip
*
* Throws on error.
*/
bool
archive_lookup(char *pathname, const char **archive,
const char **inpath, const char **suffix);
const char **inpath);
#endif