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

Method updateTree

Engine/source/gui/controls/guiFileTreeCtrl.cpp:97–143  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

95}
96
97void GuiFileTreeCtrl::updateTree()
98{
99 // Kill off any existing items
100 _destroyTree();
101
102 // Here we're going to grab our system volumes from the platform layer and create them as roots
103 //
104 // Note : that we're passing a 1 as the last parameter to Platform::dumpDirectories, which tells it
105 // how deep to dump in recursion. This is an optimization to keep from dumping the whole file system
106 // to the tree. The tree will dump more paths as necessary when the virtual parents are expanded,
107 // much as windows does.
108
109 // Determine the root path.
110
111 String rootPath = Platform::getMainDotCsDir();
112 if( !mRootPath.isEmpty() )
113 rootPath = String::ToString( "%s/%s", rootPath.c_str(), mRootPath.c_str() );
114
115 // get the files in the main.tscript dir
116 Vector<StringTableEntry> pathVec;
117 Platform::dumpDirectories( rootPath, pathVec, 0, true);
118 _dumpFiles( rootPath, pathVec, 0);
119 if( ! pathVec.empty() )
120 {
121 // get the last folder in the path.
122 char *dirname = dStrdup(rootPath);
123 U32 last = dStrlen(dirname)-1;
124 if(dirname[last] == '/')
125 dirname[last] = '\0';
126 char* lastPathComponent = dStrrchr(dirname,'/');
127 if(lastPathComponent)
128 *lastPathComponent++ = '\0';
129 else
130 lastPathComponent = dirname;
131
132 // Iterate through the returned paths and add them to the tree
133 Vector<StringTableEntry>::iterator j = pathVec.begin();
134 for( ; j != pathVec.end(); j++ )
135 {
136 char fullModPathSub [512];
137 dMemset( fullModPathSub, 0, 512 );
138 dSprintf( fullModPathSub, 512, "%s/%s", lastPathComponent, (*j) );
139 addPathToTree( *j );
140 }
141 dFree(dirname);
142 }
143}
144
145bool GuiFileTreeCtrl::onWake()
146{

Callers 1

Calls 11

_dumpFilesFunction · 0.85
dSprintfFunction · 0.85
dStrlenFunction · 0.50
dStrrchrFunction · 0.50
dMemsetFunction · 0.50
dFreeFunction · 0.50
isEmptyMethod · 0.45
c_strMethod · 0.45
emptyMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected