MCPcopy Create free account
hub / github.com/KDE/kdiff3 / fileRelPath

Method fileRelPath

src/fileaccess.cpp:736–766  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

734}
735
736QString 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
768FileAccess* FileAccess::parent() const
769{

Callers 2

subPathMethod · 0.80
testFileRelPathMethod · 0.80

Calls 4

prependMethod · 0.80
fileNameMethod · 0.80
absoluteFilePathMethod · 0.45
parentMethod · 0.45

Tested by 1

testFileRelPathMethod · 0.64