forked from organicmaps/organicmaps-tmp
Added ZipReader::IsZip()
This commit is contained in:
parent
efc5f6aa81
commit
aae0710a08
3 changed files with 13 additions and 0 deletions
|
@ -94,11 +94,13 @@ UNIT_TEST(ZipFilesList)
|
|||
FileWriter f(ZIPFILE);
|
||||
f.Write(zipBytes2, ARRAY_SIZE(zipBytes2) - 1);
|
||||
}
|
||||
TEST(ZipFileReader::IsZip(ZIPFILE), ());
|
||||
string const ZIPFILE_INVALID = "invalid_test.zip";
|
||||
{
|
||||
FileWriter f(ZIPFILE_INVALID);
|
||||
f.Write(invalidZip, ARRAY_SIZE(invalidZip) - 1);
|
||||
}
|
||||
TEST(!ZipFileReader::IsZip(ZIPFILE_INVALID), ());
|
||||
|
||||
try
|
||||
{
|
||||
|
|
|
@ -64,3 +64,12 @@ vector<string> ZipFileReader::FilesList(string const & zipContainer)
|
|||
|
||||
return filesList;
|
||||
}
|
||||
|
||||
bool ZipFileReader::IsZip(string const & zipContainer)
|
||||
{
|
||||
unzFile zip = unzOpen64(zipContainer.c_str());
|
||||
if (!zip)
|
||||
return false;
|
||||
unzClose(zip);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -16,4 +16,6 @@ public:
|
|||
ZipFileReader(string const & container, string const & file);
|
||||
|
||||
static vector<string> FilesList(string const & zipContainer);
|
||||
/// Quick version without exceptions
|
||||
static bool IsZip(string const & zipContainer);
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue