Changeset 1442 for code/branches/console
- Timestamp:
- May 27, 2008, 9:39:28 PM (16 years ago)
- Location:
- code/branches/console
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/console/CMakeLists.txt
r1186 r1442 64 64 FIND_PACKAGE(ENet) 65 65 FIND_PACKAGE(Boost REQUIRED thread) 66 FIND_PACKAGE(Boost REQUIRED filesystem) 66 67 FIND_PACKAGE(OpenAL) 67 68 FIND_PACKAGE(ALUT) -
code/branches/console/src/core/ArgumentCompletionFunctions.cc
r1441 r1442 30 30 #include <map> 31 31 32 #include <dirent.h>32 #include "boost/filesystem.hpp" 33 33 34 34 #include "ArgumentCompletionFunctions.h" … … 39 39 #include "util/Convert.h" 40 40 #include "util/String.h" 41 #include "util/SubString.h"42 41 43 42 namespace orxonox … … 55 54 ArgumentCompletionList filelist; 56 55 57 SubString tokens(fragment, "/", "", false, '\0', false, '\0', false, '\0', '\0', false, '\0'); 56 try 57 { 58 boost::filesystem::path input(fragment); 59 boost::filesystem::path startdirectory(input.branch_path()); 58 60 59 std::string startdirectory = "."; 60 if (fragment.size() > 0 && fragment[fragment.size() - 1] == '/' && tokens.size() > 0) 61 startdirectory = tokens.subSet(0, tokens.size()).join("/"); 62 else if (tokens.size() > 1) 63 startdirectory = tokens.subSet(0, tokens.size() - 1).join("/"); 61 if (!boost::filesystem::exists(startdirectory)) 62 { 63 startdirectory = "."; 64 } 65 #if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32 66 else 67 { 68 std::string dir = startdirectory.string(); 69 if (dir.size() > 0 && dir[dir.size() - 1] == ':') 70 startdirectory = dir + "/"; 71 } 72 #endif 64 73 65 struct stat fileInfo; 66 struct dirent *currentFile; 67 DIR *handler = 0; 74 boost::filesystem::directory_iterator file(startdirectory); 75 boost::filesystem::directory_iterator end; 68 76 69 handler = opendir(startdirectory.c_str()); 70 if (handler) 71 { 72 while ((currentFile = readdir(handler)) != 0) 77 while (file != end) 73 78 { 74 if (strcmp(currentFile->d_name, ".") && strcmp(currentFile->d_name, "..")) 75 { 76 std::string path = startdirectory + "/" + currentFile->d_name; 77 if (stat(path.c_str(), &fileInfo) == -1) 78 { 79 closedir(handler); 80 break; 81 } 82 83 if (S_ISREG(fileInfo.st_mode)) // normal file 84 filelist.push_back(ArgumentCompletionListElement(path, getLowercase(path), currentFile->d_name)); 85 else if (S_ISDIR(fileInfo.st_mode)) // directory 86 dirlist.push_back(ArgumentCompletionListElement(path + "/", getLowercase(path) + "/", std::string(currentFile->d_name) + "/")); 87 else // special file 88 filelist.push_back(ArgumentCompletionListElement(path, getLowercase(path), currentFile->d_name)); 89 } 79 if (boost::filesystem::is_directory(*file)) 80 dirlist.push_back(ArgumentCompletionListElement((*file).string() + "/", getLowercase((*file).string()) + "/", (*file).leaf() + "/")); 81 else 82 filelist.push_back(ArgumentCompletionListElement((*file).string(), getLowercase((*file).string()), (*file).leaf())); 83 ++file; 90 84 } 91 92 closedir(handler);93 85 } 86 catch (...) {} 94 87 95 88 filelist.insert(filelist.begin(), dirlist.begin(), dirlist.end()); -
code/branches/console/src/core/CMakeLists.txt
r1390 r1442 46 46 ${OIS_LIBRARIES} 47 47 ${Boost_thread_LIBRARIES} 48 ${Boost_filesystem_LIBRARIES} 48 49 ) -
code/branches/console/src/core/OutputBuffer.cc
r1334 r1442 81 81 82 82 if (eof) 83 {84 83 this->stream_.flush(); 84 85 if (eof || fail) 85 86 this->stream_.clear(); 86 }87 87 88 88 return (!eof && !fail);
Note: See TracChangeset
for help on using the changeset viewer.