//===----------------------------------------------------------------------===// // Client //===----------------------------------------------------------------------===// DirEntries Client::list(const char* pPathOrURL, svn_opt_revision_t* pRevision, bool pRecurse) throw(ClientException) { Pool pool; apr_hash_t* hash; svn_error_t* error = svn_client_ls(&hash, pPathOrURL, pRevision, pRecurse, m_Context, pool.handler()); if (nullptr != error) throw ClientException(error); DirEntries entries; apr_hash_index_t* item = apr_hash_first(pool.handler(), hash); while (nullptr != item) { const char* entryname = nullptr; svn_dirent_t* dirent; apr_hash_this(item, (const void **)&entryname, nullptr, (void **)&dirent); entries.push_back(DirEntry(entryname, dirent)); item = apr_hash_next(item); } return entries; }
static svn_error_t* listEntriesFunc(void *baton, const char *path, const svn_dirent_t *dirent, const svn_lock_t *lock, const char *abs_path, apr_pool_t *pool) { if (!isEmpty(path)) { DirEntries * entries = static_cast<DirEntries *>(baton); entries->push_back( DirEntry(path, const_cast<svn_dirent_t *>(dirent), lock)); } return 0; }
// Reads the directory referred to by 'pathBytes', adding each directory entry // to 'entries'. static bool readDirectory(JNIEnv* env, jstring javaPath, DirEntries& entries) { ScopedUtfChars path(env, javaPath); if (path.c_str() == NULL) { return false; } ScopedReaddir dir(path.c_str()); const char* filename; while ((filename = dir.next()) != NULL) { if (strcmp(filename, ".") != 0 && strcmp(filename, "..") != 0) { // TODO: this hides allocation failures from us. Push directory iteration up into Java? entries.push_back(filename); } } return !dir.isBad(); }