| 94 | } |
| 95 | |
| 96 | void 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 | |
| 144 | bool GuiFileTreeCtrl::onWake() |
| 145 | { |
no test coverage detected