Changeset 7624 in orxonox.OLD for branches/qt_gui/src/lib/util/directory.cc
- Timestamp:
- May 16, 2006, 9:04:24 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/qt_gui/src/lib/util/directory.cc
r7610 r7624 36 36 37 37 #include "directory.h" 38 39 #if not defined (__WIN32__) 40 #include <sys/stat.h> 41 #include <sys/types.h> 42 #endif 38 43 Directory::Directory(const std::string& directoryName) 39 44 : willfail(false) … … 41 46 this->handle = 0; 42 47 this->willfail = true; 43 this->open(directoryName);44 48 } 45 49 46 50 Directory::~Directory() 47 51 { 48 this->close();49 52 } 50 53 51 54 bool Directory::open(const std::string& directoryName) 52 55 { 53 #if defined(OSLINK_OSDIR_POSIX)56 #if not defined(__WIN32__) 54 57 if (this->handle != NULL) 55 58 this->close(); … … 66 69 willfail = true; 67 70 } 68 #el if defined(OSLINK_OSDIR_WINDOWS)71 #else 69 72 if (handle != INVALID_HANDLE_VALUE) 70 73 this->close(); … … 99 102 } 100 103 101 voidDirectory::close()104 bool Directory::close() 102 105 { 103 #if defined(OSLINK_OSDIR_POSIX)106 #if not defined(__WIN32__) 104 107 if (this->handle != NULL) 105 108 closedir(handle); 106 109 this->handle = NULL; 107 #el if defined(OSLINK_OSDIR_WINDOWS)110 #else 108 111 if (handle != INVALID_HANDLE_VALUE) 109 112 FindClose(handle); … … 112 115 this->willfail = true; 113 116 this->current = ""; 117 return true; 114 118 } 115 119 … … 118 122 std::string Directory::next() 119 123 { 120 #if defined(OSLINK_OSDIR_POSIX)124 #if not defined(__WIN32__) 121 125 std::string prev(current); 122 126 dirent* entry = readdir(handle); … … 127 131 return prev; 128 132 129 #el if defined(OSLINK_OSDIR_WINDOWS)133 #else 130 134 std::string prev = current; 131 135 WIN32_FIND_DATA entry; … … 138 142 #endif 139 143 } 144 145 146 bool Directory::create() 147 { 148 #if not defined (__WIN32__) 149 return (!mkdir(this->name().c_str(), 0777)); 150 #else 151 return (!CreateDirectory(this->name().c_str(), NULL)); 152 #endif 153 }
Note: See TracChangeset
for help on using the changeset viewer.