Changeset 7425 in orxonox.OLD for trunk/src/lib/util
- Timestamp:
- Apr 28, 2006, 6:05:02 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/util/osdir.h
r7422 r7425 129 129 { 130 130 public: 131 Directory(const std::string& aName) 132 : handle(INVALID_HANDLE_VALUE), willfail(false) 133 { 131 Directory(const std::string& directoryName = "") 132 : handle(INVALID_HANDLE_VALUE), willfail(true) 133 { 134 this->open(directoryName); 135 } 136 137 ~Directory() 138 { 139 this->close 140 } 141 142 bool open(const std::string& directoryName) 143 { 144 if (handle != INVALID_HANDLE_VALUE) 145 this->close(); 146 134 147 // First check the attributes trying to access a non-Directory with 135 148 // FindFirstFile takes ages 136 DWORD attrs = GetFileAttributes( aName.c_str());149 DWORD attrs = GetFileAttributes(directoryName.c_str()); 137 150 if ( (attrs == 0xFFFFFFFF) || ((attrs && FILE_ATTRIBUTE_DIRECTORY) == 0) ) 138 151 { … … 140 153 return; 141 154 } 142 std::string Full( aName);155 std::string Full(directoryName); 143 156 // Circumvent a problem in FindFirstFile with c:\\* as parameter 144 157 if ( (Full.length() > 0) && (Full[Full.length()-1] != '\\') ) … … 151 164 current = entry.cFileName; 152 165 } 153 ~Directory() 166 167 void close() 154 168 { 155 169 if (handle != INVALID_HANDLE_VALUE) 156 170 FindClose(handle); 171 this->willfail = true; 157 172 } 158 173 … … 161 176 return willfail ? (void*)0:(void*)(-1); 162 177 } 178 163 179 std::string next() 164 180 { … … 172 188 return current; 173 189 } 190 191 174 192 private: 175 193 HANDLE handle;
Note: See TracChangeset
for help on using the changeset viewer.