Example #1
0
bool ZIPProvider::ZIPHandle::isDir(const FileName & directory) {
	if (directory.getDir().empty()) {
		// Always return true for the root archive directory.
		return true;
	}
	struct zip_stat sb;
	zip_stat_init(&sb);
	if (zip_stat(handle, directory.getDir().c_str(), 0, &sb) == -1) {
		return false;
	}
	std::string entry(sb.name);
	return (entry.back() == '/' && sb.size == 0);
}
Example #2
0
AbstractFSProvider::status_t ZIPProvider::dir(const FileName & url, std::list<
		FileName> & result, uint8_t flags) {
	std::lock_guard<std::mutex> lock(handlesMutex);
	std::string archiveFileName;
	FileName localPath;
	decomposeURL(url, archiveFileName, localPath);
	ZIPHandle * handle = getZIPHandle(archiveFileName);
	if (handle == nullptr) {
		return FAILURE;
	}

	// Make sure all data has been written.
	if (handle->isChanged()) {
		delete handle;
		openHandles.erase(archiveFileName);
		handle = getZIPHandle(archiveFileName);
	}

	if (handle == nullptr) {
		return OK;
	}

	return handle->dir(localPath.getDir(), result, flags);
}