MCPcopy Create free account
hub / github.com/GarageGames/Torque3D / recurseInsert

Method recurseInsert

Engine/source/gui/controls/guiFileTreeCtrl.cpp:272–380  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 15

dStrcpyFunction · 0.85
dSprintfFunction · 0.85
dStrncpyFunction · 0.85
_isDirInMainDotCsPathFunction · 0.85
_hasChildrenFunction · 0.85
findChildByValueMethod · 0.80
setVirtualParentMethod · 0.80
setNormalImageMethod · 0.80
setExpandedImageMethod · 0.80
dMemsetFunction · 0.50
dStrlenFunction · 0.50
dMemcpyFunction · 0.50

Tested by

no test coverage detected