std::vector<std::string> find_layout_files(const std::string& apk_directory) { std::vector<std::string> layout_files; std::string root = apk_directory + std::string("/res"); path_t res(root); if (exists(res) && is_directory(res)) { for (auto it = dir_iterator(res); it != dir_iterator(); ++it) { auto const& entry = *it; path_t entry_path = entry.path(); if (is_directory(entry_path) && starts_with(entry_path.filename().string().c_str(), "layout")) { for (auto lit = dir_iterator(entry_path); lit != dir_iterator(); ++lit) { auto const& layout_entry = *lit; path_t layout_path = layout_entry.path(); if (is_regular_file(layout_path)) { layout_files.push_back(layout_path.string()); } } } } } return layout_files; }
void SlideshowController::refresh_directory_list() { QDirIterator dir_iterator(slideshow_data_model_->main_image_folder_path(), QDir::Dirs | QDir::NoSymLinks | QDir::Hidden); slideshow_data_model_->slide_dir_list()->clear(); // Make sure profile folder exists ensure_folder_structure(); // Iterate through main_image_folder to obtain // first-level subdirectories. Add subdirectories // to a list if (QDir(slideshow_data_model_->main_image_folder_path()). entryList().size() == 2) { qWarning() << "Directory is empty."; } else { qWarning() << "Directory is not empty"; while(dir_iterator.hasNext()) { dir_iterator.next(); if (dir_iterator.fileName() != "." && dir_iterator.fileName() !="..") { SlideDirectory temp; temp.set_dir_name(dir_iterator.fileName()); temp.set_full_path(dir_iterator.fileInfo().absoluteFilePath()); if (temp.name().contains("-info")) { temp.set_marketing_folder(true); } if (temp.name().at(0) == '.') { temp.set_exclude_from_show(true); } else { temp.set_exclude_from_show(false); } slideshow_data_model_->slide_dir_list()->append(temp); } } } qWarning() << "[size2]: " << slideshow_data_model_->slide_dir_list()->size(); }
//! scan one directory indicated by path_ /// This method conforms to the linked_list_str_foreach_t type. /// @param path_ the directory to scan /// @param manager_ a plugin_manager_t instance /// @return FUNC_OK or the error returned by last plugin_manager_scan_an_inf() static func_error_t plugin_manager_scan_a_path(const char * path_, void * manager_) { func_error_t err_code = FUNC_OK; inf_dbg_message (" path %s", path_); access_rights_t ar = du_existsdir (path_); if ( ( ar & DU_READABLE ) && ( ar & DU_EXECUTABLE ) ) { err_code = dir_iterator ( path_, "*.inf", DIR_ITERATOR_EXCLUDE_DIRECTORIES, plugin_manager_scan_an_inf, manager_); } else { inf_dbg_message (" path %s not used; exists() returns %d", path_, (int)ar); } return err_code; }
QVector<QString> CSV::Find(const QDir &i_dir) { QStringList filters("*.csv"); QDirIterator dir_iterator(i_dir.path(), filters, QDir::NoFilter, QDirIterator::Subdirectories); QVector<QString> res; while(1) { if(dir_iterator.fileInfo().suffix() == "csv") res.append(dir_iterator.filePath()); if(!dir_iterator.hasNext()) break; dir_iterator.next(); } return res; }
QStringList uavCore::searchFiles( const QString &path, QStringList &filters, QWidget *parent /*= 0 */, const QString &title /*= "" */ ) { QStringList list; QDir dir(path); if (!dir.exists()) { return list; } //QProgressDialog dialog; //if (parent) //{ // dialog.setParent(parent); // dialog.setLabelText(title); // dialog.setWindowTitle(title); // dialog.setCancelButtonText("取消"); // dialog.setMinimum(0); // dialog.setMaximum(0); // dialog.setWindowModality(Qt::WindowModal); // dialog.show(); //} QDirIterator dir_iterator(path, filters, QDir::Files | QDir::NoSymLinks, QDirIterator::Subdirectories); while (dir_iterator.hasNext()) { dir_iterator.next(); QFileInfo file_info = dir_iterator.fileInfo(); list.append(file_info.filePath()); //if (parent) //{ // QApplication::processEvents(); // if (dialog.wasCanceled()) // { // list.clear(); // return list; // } //} } return list; }