| 734 | } |
| 735 | |
| 736 | QString FileAccess::fileRelPath() const |
| 737 | { |
| 738 | #ifndef AUTOTEST |
| 739 | assert(m_pParent == nullptr || m_baseDir == m_pParent->m_baseDir); |
| 740 | #endif |
| 741 | QString path; |
| 742 | |
| 743 | if(isLocal()) |
| 744 | { |
| 745 | path = m_baseDir.relativeFilePath(m_fileInfo.absoluteFilePath()); |
| 746 | |
| 747 | return path; |
| 748 | } |
| 749 | else |
| 750 | { |
| 751 | //Stop right before the root directory |
| 752 | if(parent() == nullptr) return QString(); |
| 753 | |
| 754 | const FileAccess* curEntry = this; |
| 755 | path = fileName(); |
| 756 | //Avoid recursively calling FileAccess::fileRelPath or we can get very large stacks. |
| 757 | curEntry = curEntry->parent(); |
| 758 | while(curEntry != nullptr) |
| 759 | { |
| 760 | if(curEntry->parent()) |
| 761 | path.prepend(curEntry->fileName() + '/'); |
| 762 | curEntry = curEntry->parent(); |
| 763 | } |
| 764 | return path; |
| 765 | } |
| 766 | } |
| 767 | |
| 768 | FileAccess* FileAccess::parent() const |
| 769 | { |