Skip to content

Commit

Permalink
Merge pull request #28 from notspiff/add_exists
Browse files Browse the repository at this point in the history
Add Exists() implementation
  • Loading branch information
notspiff authored Feb 14, 2019
2 parents 6d39012 + ab69115 commit 2ba1102
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
21 changes: 20 additions & 1 deletion src/ArchiveFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ static std::string URLEncode(const std::string& strURLData)
else
{
char temp[128];
sprintf(temp,"%%%2.2X", (unsigned int)((unsigned char)kar));
sprintf(temp,"%%%2.2x", (unsigned int)((unsigned char)kar));
strResult += temp;
}
}
Expand Down Expand Up @@ -299,6 +299,25 @@ class CArchiveFile : public kodi::addon::CInstanceVFS

virtual bool Exists(const VFSURL& url) override
{
ArchiveCtx* ctx = new ArchiveCtx;
if (!ctx->Open(url.hostname))
{
delete ctx;
return false;
}

std::string encoded = URLEncode(url.hostname);
std::vector<kodi::vfs::CDirEntry> items;
ListArchive(ctx->ar, "archive://"+encoded+"/", items, false, "");
archive_read_free(ctx->ar);
delete ctx;

for (kodi::vfs::CDirEntry& item : items)
{
if (item.Path() == url.url)
return true;
}

return false;
}

Expand Down
2 changes: 1 addition & 1 deletion vfs.libarchive/addon.xml.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<addon
id="vfs.libarchive"
version="1.0.4"
version="1.0.5"
name="Archive support"
provider-name="spiff">
<requires>@ADDON_DEPENDS@</requires>
Expand Down

0 comments on commit 2ba1102

Please sign in to comment.