size_t ZIPProvider::fileSize(const FileName & url) { std::lock_guard<std::mutex> lock(handlesMutex); std::string archiveFileName; FileName file; decomposeURL(url, archiveFileName, file); ZIPHandle * handle = getZIPHandle(archiveFileName); if (handle == nullptr) { return 0; } // Make sure all data has been written. if (handle->isChanged()) { delete handle; openHandles.erase(archiveFileName); handle = getZIPHandle(archiveFileName); } return handle->fileSize(file); }
AbstractFSProvider::status_t ZIPProvider::readFile(const FileName & url, std::vector<uint8_t> & data) { std::lock_guard<std::mutex> lock(handlesMutex); std::string archiveFileName; FileName file; decomposeURL(url, archiveFileName, file); 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); } return handle->readFile(file, data); }
AbstractFSProvider::status_t ZIPProvider::remove(const FileName & url) { auto lock = Concurrency::createLock(*handlesMutex); std::string archiveFileName; FileName file; decomposeURL(url, archiveFileName, file); 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); } return handle->removeDir(file); }
AbstractFSProvider::status_t ZIPProvider::writeFile(const FileName & url, const std::vector<uint8_t> & data, bool overwrite) { std::lock_guard<std::mutex> lock(handlesMutex); std::string archiveFileName; FileName file; decomposeURL(url, archiveFileName, file); ZIPHandle * handle = getZIPHandle(archiveFileName, true); if (handle == nullptr) { return FAILURE; } return handle->writeFile(file, data, overwrite); }
AbstractFSProvider::status_t ZIPProvider::makeDir(const FileName & url) { if(isDir(url)) { return AbstractFSProvider::OK; } std::lock_guard<std::mutex> lock(handlesMutex); std::string archiveFileName; FileName file; decomposeURL(url, archiveFileName, file); ZIPHandle * handle = getZIPHandle(archiveFileName, true); if (handle == nullptr) { return FAILURE; } return handle->makeDir(file); }
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); }
AbstractFSProvider::status_t ZIPProvider::makeDir(const FileName & url) { if(isDir(url)) { return AbstractFSProvider::OK; } auto lock = Concurrency::createLock(*handlesMutex); std::string archiveFileName; FileName file; decomposeURL(url, archiveFileName, file); ZIPHandle * handle = getZIPHandle(archiveFileName, true); if (handle == nullptr) { return FAILURE; } return handle->makeDir(file); }