FSArchNode* FSArchNode::findByFsPath( FSPath& fsPath, int fsPathLevel ) { FSString* curName = fsPath.GetItem( fsPathLevel ); if ( parentDir == nullptr && fsPathLevel == fsPath.Count() - 1 && ( curName == nullptr || curName->GetUnicode() == 0 || curName->GetUnicode()[0] == 0 ) ) { // request to find root node, and we are root return this; } if ( name.Cmp( *curName ) == 0 ) { if ( fsPath.Count() <= fsPathLevel ) { // exact match return this; } FSString* childName = fsPath.GetItem( fsPathLevel + 1 ); FSArchNode* n = findByName( *childName ); if ( n == nullptr ) { return nullptr; } if ( fsPath.Count() <= fsPathLevel + 2 ) { // no further recursion return n; } if ( n->IsDir() ) { // recurse into subdir return n->findByFsPath( fsPath, fsPathLevel + 1 ); } } return nullptr; }