Changeset 7624 in orxonox.OLD for branches/qt_gui/src/lib
- Timestamp:
- May 16, 2006, 9:04:24 AM (19 years ago)
- Location:
- branches/qt_gui/src/lib
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/qt_gui/src/lib/parser/ini_parser/ini_parser.h
r7256 r7624 10 10 11 11 #define PARSELINELENGHT 512 //!< how many chars to read at once 12 #ifndef NULL13 #define NULL 0x0 //!< NULL14 #endif15 12 13 #include "src/lib/util/file.h" 16 14 #include <list> 17 #include <string>18 15 19 16 //! ini-file parser -
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 } -
branches/qt_gui/src/lib/util/directory.h
r7610 r7624 1 /*! 2 * @file directory.h 3 * @brief Definition of the Directory Handler class 4 */ 5 6 1 7 /** 2 8 * Copyright (C) 2002 Bart Vanhauwaert … … 20 26 #define __DIRECTORY_H_ 21 27 22 #if defined(unix) || defined(__unix) || defined(__unix__) 23 #define OSLINK_OSDIR_POSIX 24 #elif defined(_WIN32) 25 #define OSLINK_OSDIR_WINDOWS 28 #include "file.h" 29 30 #if not defined (__WIN32__) 31 #include <sys/types.h> 32 #include <dirent.h> 26 33 #else 27 #define OSLINK_OSDIR_NOTSUPPORTED 34 #include <windows.h> 35 #include <winbase.h> 28 36 #endif 29 37 30 #include <string> 31 32 #if defined(OSLINK_OSDIR_NOTSUPPORTED) 33 #warning DIRECTORY NOT SUPPORTET 34 35 #elif defined(OSLINK_OSDIR_POSIX) 36 #include <sys/types.h> 37 #include <dirent.h> 38 39 #elif defined(OSLINK_OSDIR_WINDOWS) 40 41 /// HACK 42 #ifdef DATADIR 43 #undef DATADIR 44 #endif 45 46 #include <windows.h> 47 #include <winbase.h> 48 49 #endif 50 51 class Directory 38 class Directory : public File 52 39 { 53 40 public: … … 55 42 ~Directory(); 56 43 57 bool open(const std::string& directoryName);58 v oidclose();44 virtual bool open(const std::string& directoryName); 45 virtual bool close(); 59 46 operator void*() const { return willfail ? (void*)0:(void*)(-1); } 60 47 61 48 std::string next(); 62 49 50 bool create(); 51 63 52 private: 64 #if defined(OSLINK_OSDIR_POSIX)53 #if not defined(__WIN32__) 65 54 DIR* handle; 66 #el if defined(OSLINK_OSDIR_WINDOWS)67 55 #else 56 HANDLE handle; 68 57 #endif 69 58 bool willfail; -
branches/qt_gui/src/lib/util/file.cc
r7623 r7624 263 263 * 264 264 * if the File was opened, it will be closed throuh this function. 265 * The File will also be closed, if the File was not renamed. 265 266 */ 266 267 bool File::rename(const File& destination) 267 268 { 269 this->close(); 270 268 271 if (!std::rename(this->_name.c_str(), destination.name().c_str())) 269 272 { 270 this->close();271 273 this->_name = destination.name(); 272 274 this->statFile(); 273 274 275 return true; 275 276 } … … 292 293 } 293 294 fclose(stream); 295 296 this->statFile(); 294 297 return true; 295 298 }
Note: See TracChangeset
for help on using the changeset viewer.