This is a recursive method which tries to match a path to a specifiq FileSystemItem item which has the path; Here startIndex is the position of the separator
| 424 | // FileSystemItem item which has the path; |
| 425 | // Here startIndex is the position of the separator |
| 426 | boost::shared_ptr<FileSystemItem> |
| 427 | FileSystemItem::matchPath(const QStringList& path, |
| 428 | int startIndex) const |
| 429 | { |
| 430 | const QString& pathBit = path.at(startIndex); |
| 431 | |
| 432 | for (U32 i = 0; i < _imp->children.size(); ++i) { |
| 433 | const boost::shared_ptr<FileSystemItem>& child = _imp->children[i]; |
| 434 | |
| 435 | if ( child && (child->fileName() == pathBit) ) { |
| 436 | if (startIndex == path.size() - 1) { |
| 437 | return child; |
| 438 | } else { |
| 439 | return child->matchPath(path, startIndex + 1); |
| 440 | } |
| 441 | } |
| 442 | } |
| 443 | |
| 444 | return boost::shared_ptr<FileSystemItem>(); |
| 445 | } |
| 446 | |
| 447 | //////////////FileSystemModel |
| 448 |
no test coverage detected