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

Method recurseInsert

Engine/source/gui/controls/guiFileTreeCtrl.cpp:273–381  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

271}
272
273void 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;

Callers

nothing calls this directly

Calls 15

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

Tested by

no test coverage detected