================ CPathTreeCtrl::AddPathToTree Adds a new item to the tree. Assumes new paths after the current stack path do not yet exist. ================ */
| 150 | ================ |
| 151 | */ |
| 152 | HTREEITEM CPathTreeCtrl::AddPathToTree( const idStr &pathName, const int id, idPathTreeStack &stack ) { |
| 153 | int lastSlash; |
| 154 | idStr itemName, tmpPath; |
| 155 | HTREEITEM item; |
| 156 | |
| 157 | lastSlash = pathName.Last( '/' ); |
| 158 | |
| 159 | while( stack.Num() > 1 ) { |
| 160 | if ( pathName.Icmpn( stack.TopName(), stack.TopNameLength() ) == 0 ) { |
| 161 | break; |
| 162 | } |
| 163 | stack.Pop(); |
| 164 | } |
| 165 | |
| 166 | while( lastSlash > stack.TopNameLength() ) { |
| 167 | pathName.Mid( stack.TopNameLength(), pathName.Length(), tmpPath ); |
| 168 | tmpPath.Left( tmpPath.Find( '/' ), itemName ); |
| 169 | item = InsertItem( itemName, stack.TopItem() ); |
| 170 | stack.Push( item, itemName ); |
| 171 | } |
| 172 | |
| 173 | pathName.Mid( stack.TopNameLength(), pathName.Length(), itemName ); |
| 174 | item = InsertItem( itemName, stack.TopItem() ); |
| 175 | SetItemData( item, id ); |
| 176 | |
| 177 | return item; |
| 178 | } |
| 179 | |
| 180 | /* |
| 181 | ================ |
no test coverage detected