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

Method updateTree

Engine/source/gui/controls/guiFileTreeCtrl.cpp:96–142  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

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