| 160 | } |
| 161 | |
| 162 | std::vector<FileData*> FolderData::getFilesRecursive(bool onlyFiles) const |
| 163 | { |
| 164 | std::vector<FileData*> temp; |
| 165 | //now check if a child is a folder and get those children in turn |
| 166 | std::vector<FileData*>::const_iterator fdit = mFileVector.cbegin(); |
| 167 | while(fdit != mFileVector.cend()) { |
| 168 | //dynamically try to cast to FolderData type |
| 169 | FolderData * folder = dynamic_cast<FolderData*>(*fdit); |
| 170 | if (folder != nullptr) { |
| 171 | //add this onyl when user wanted it |
| 172 | if (!onlyFiles) { |
| 173 | temp.push_back(*fdit); |
| 174 | } |
| 175 | //worked. Is actual folder data. recurse |
| 176 | std::vector<FileData*> children = folder->getFilesRecursive(onlyFiles); |
| 177 | //insert children into return vector |
| 178 | temp.insert(temp.end(), children.cbegin(), children.cend()); |
| 179 | } |
| 180 | else { |
| 181 | temp.push_back(*fdit); |
| 182 | } |
| 183 | ++fdit; |
| 184 | } |
| 185 | return temp; |
| 186 | } |
no test coverage detected