| 271 | } |
| 272 | |
| 273 | void GuiFileTreeCtrl::recurseInsert( Item* parent, StringTableEntry path ) |
| 274 | { |
| 275 | if( !path ) |
| 276 | return; |
| 277 | |
| 278 | char szPathCopy [ 1024 ]; |
| 279 | dMemset( szPathCopy, 0, 1024 ); |
| 280 | dStrcpy( szPathCopy, path, 1024 ); |
| 281 | |
| 282 | // Jump over the first character if it's a root / |
| 283 | char *curPos = szPathCopy; |
| 284 | if( *curPos == '/' ) |
| 285 | curPos++; |
| 286 | |
| 287 | char szValue[1024]; |
| 288 | dMemset( szValue, 0, 1024 ); |
| 289 | if( parent ) |
| 290 | { |
| 291 | dMemset( szValue, 0, sizeof( szValue ) ); |
| 292 | dSprintf( szValue, sizeof( szValue ), "%s/%s", parent->getValue(), curPos ); |
| 293 | } |
| 294 | else |
| 295 | { |
| 296 | dStrncpy( szValue, curPos, sizeof( szValue ) ); |
| 297 | szValue[ sizeof( szValue ) - 1 ] = 0; |
| 298 | } |
| 299 | |
| 300 | const U32 valueLen = dStrlen( szValue ); |
| 301 | char* value = new char[ valueLen + 1 ]; |
| 302 | dMemcpy( value, szValue, valueLen + 1 ); |
| 303 | |
| 304 | char *delim = dStrchr( curPos, '/' ); |
| 305 | if ( delim ) |
| 306 | { |
| 307 | // terminate our / and then move our pointer to the next character (rest of the path) |
| 308 | *delim = 0x00; |
| 309 | delim++; |
| 310 | } |
| 311 | S32 itemIndex = 0; |
| 312 | // only insert blindly if we have no root |
| 313 | if( !parent ) |
| 314 | itemIndex = insertItem( 0, curPos, curPos ); |
| 315 | else |
| 316 | { |
| 317 | bool allowed = (_isDirInMainDotCsPath(value) || matchesFilters(value)); |
| 318 | Item *exists = parent->findChildByValue( szValue ); |
| 319 | if( allowed && !exists && String::compare( curPos, "" ) != 0 ) |
| 320 | { |
| 321 | // Since we're adding a child this parent can't be a virtual parent, so clear that flag |
| 322 | parent->setVirtualParent( false ); |
| 323 | |
| 324 | itemIndex = insertItem( parent->getID(), curPos); |
| 325 | Item *newitem = getItem(itemIndex); |
| 326 | newitem->setValue( value ); |
| 327 | } |
| 328 | else |
| 329 | { |
| 330 | itemIndex = ( parent != NULL ) ? ( ( exists != NULL ) ? exists->getID() : -1 ) : -1; |
nothing calls this directly
no test coverage detected