Changeset 7423 in orxonox.OLD for trunk/src/lib/shell/shell_completion_plugin.cc
- Timestamp:
- Apr 28, 2006, 5:54:50 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/shell/shell_completion_plugin.cc
r7422 r7423 31 31 { 32 32 CompletorDefault::CompletorDefault(const MultiType* value) 33 :_value(value)33 :_value(value) 34 34 { } 35 35 … … 87 87 88 88 CompletorFileSystem::CompletorFileSystem(const std::string& fileExtension, 89 const std::string& subDir, 90 StartDirectory startDir) 91 : _fileExtension(fileExtension), _startDir(startDir), _subDir(subDir) 89 const std::string& subDir) 90 : _fileExtension(fileExtension), _subDir(subDir) 92 91 { } 93 92 … … 95 94 void CompletorFileSystem::addToCompleteList(std::vector<std::string>& completionList, const std::string& completionBegin) const 96 95 { 96 OS::Directory dir; 97 97 98 if (completionBegin.empty()) // if we do not yet have the beginning of the line, start with the chosen startDir. 98 99 { 99 OS::Directory dir; 100 if (this->_startDir == StartAtDataDir) 101 { 102 dir.open(ResourceManager::getInstance()->getDataDir()); 103 } 104 105 else if(this->_startDir == StartAtRoot) 106 dir.open("/"); 107 else 108 dir.open(ResourceManager::homeDirCheck("~/")); 109 100 dir.open(ResourceManager::getInstance()->getDataDir() + this->_subDir); 110 101 while(dir) 111 102 { 112 printf("%s\n", "one\n"); 113 completionList.push_back(dir.next()); 103 completionList.push_back(this->_subDir + "/" + dir.next()); 104 } 105 } 106 else 107 { 108 std::string directoryName; 109 std::string::size_type pos = completionBegin.find_last_of("/"); 110 if (pos != std::string::npos) 111 directoryName = completionBegin.substr(0, pos); 112 113 dir.open(ResourceManager::getInstance()->getDataDir() + directoryName); 114 115 std::string fileName; 116 std::string currFile; 117 while(dir) 118 { 119 currFile = dir.next(); 120 if (currFile[0] == '.') 121 continue; 122 123 if (directoryName.empty()) 124 fileName = currFile; 125 else 126 fileName = directoryName + '/' + currFile; 127 128 if (!nocaseCmp(completionBegin, fileName, completionBegin.size()) && 129 (this->_fileExtension.empty() || fileName.find(this->_fileExtension) != std::string::npos)) 130 { 131 printf ("File %s\n", fileName.c_str()); 132 completionList.push_back(fileName); 133 continue; 134 } 135 printf("%s\n", (ResourceManager::getInstance()->getDataDir() + fileName).c_str()); 136 if (!nocaseCmp(completionBegin, fileName, completionBegin.size()) && 137 ResourceManager::isDir(ResourceManager::getInstance()->getDataDir() + fileName)) 138 { 139 printf("Dir %s\n", fileName.c_str()); 140 completionList.push_back(fileName + "/"); 141 } 114 142 } 115 143 } 116 144 } 145 117 146 CompletorPlugin* CompletorFileSystem::clone() const 118 147 { 119 return new CompletorFileSystem(this->_fileExtension, this->_subDir , this->_startDir);148 return new CompletorFileSystem(this->_fileExtension, this->_subDir); 120 149 } 121 150
Note: See TracChangeset
for help on using the changeset viewer.