Changeset 5480 in orxonox.OLD for trunk/src/util/loading
- Timestamp:
- Nov 3, 2005, 9:08:19 PM (19 years ago)
- Location:
- trunk/src/util/loading
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/util/loading/resource_manager.cc
r5479 r5480 60 60 this->dataDir = new char[3]; 61 61 strcpy(this->dataDir, "./"); 62 this-> setDataDir("./data");62 this->tryDataDir("./data"); 63 63 this->imageDirs = new tList<char>; 64 64 this->resourceList = new tList<Resource>; … … 99 99 * sets the data main directory 100 100 * @param dataDir the DataDirectory. 101 */101 */ 102 102 bool ResourceManager::setDataDir(const char* dataDir) 103 103 { 104 104 char* realDir = ResourceManager::homeDirCheck(dataDir); 105 105 if (isDir(realDir)) 106 { 107 delete[] this->dataDir; 108 if (dataDir[strlen(dataDir)-1] == '/' || dataDir[strlen(dataDir)-1] == '\\') 109 { 110 this->dataDir = new char[strlen(realDir)+1]; 111 strcpy(this->dataDir, realDir); 112 } 113 else 114 { 115 this->dataDir = new char[strlen(realDir)+2]; 116 strcpy(this->dataDir, realDir); 117 this->dataDir[strlen(realDir)] = '/'; 118 this->dataDir[strlen(realDir)+1] = '\0'; 119 } 120 delete[] realDir; 121 return true; 122 } 123 else 124 { 125 PRINTF(1)("%s is not a Directory, and can not be the Data Directory, leaving as %s \n", realDir, this->dataDir); 126 delete[] realDir; 127 return false; 128 } 129 } 130 131 /** 132 * checks for the DataDirectory, by looking if 133 * @param fileInside is inisde?? 134 */ 135 bool ResourceManager::checkDataDir(const char* fileInside) 106 { 107 delete[] this->dataDir; 108 if (dataDir[strlen(dataDir)-1] == '/' || dataDir[strlen(dataDir)-1] == '\\') 109 { 110 this->dataDir = new char[strlen(realDir)+1]; 111 strcpy(this->dataDir, realDir); 112 } 113 else 114 { 115 this->dataDir = new char[strlen(realDir)+2]; 116 strcpy(this->dataDir, realDir); 117 this->dataDir[strlen(realDir)] = '/'; 118 this->dataDir[strlen(realDir)+1] = '\0'; 119 } 120 delete[] realDir; 121 return true; 122 } 123 else 124 { 125 PRINTF(1)("%s is not a Directory, and can not be the Data Directory, leaving as %s \n", realDir, this->dataDir); 126 delete[] realDir; 127 return false; 128 } 129 } 130 131 /** 132 * sets the data main directory 133 * @param dataDir the DataDirectory. 134 * 135 * this is essentially the same as setDataDir, but it ommits the error-message 136 */ 137 bool ResourceManager::tryDataDir(const char* dataDir) 138 { 139 char* realDir = ResourceManager::homeDirCheck(dataDir); 140 if (isDir(realDir)) 141 { 142 delete[] this->dataDir; 143 if (dataDir[strlen(dataDir)-1] == '/' || dataDir[strlen(dataDir)-1] == '\\') 144 { 145 this->dataDir = new char[strlen(realDir)+1]; 146 strcpy(this->dataDir, realDir); 147 } 148 else 149 { 150 this->dataDir = new char[strlen(realDir)+2]; 151 strcpy(this->dataDir, realDir); 152 this->dataDir[strlen(realDir)] = '/'; 153 this->dataDir[strlen(realDir)+1] = '\0'; 154 } 155 delete[] realDir; 156 return true; 157 } 158 } 159 160 161 162 /** 163 * checks for the DataDirectory, by looking if 164 * @param fileInside is iniside of the given directory. 165 */ 166 bool ResourceManager::verifyDataDir(const char* fileInside) 136 167 { 137 168 bool retVal; -
trunk/src/util/loading/resource_manager.h
r5479 r5480 107 107 inline const char* getDataDir() const { return this->dataDir; }; 108 108 109 bool checkDataDir(const char* fileInside); 110 bool addImageDir(const char* imageDir); 109 110 bool tryDataDir(const char* dataDir); 111 bool verifyDataDir(const char* fileInside); 112 bool addImageDir(const char* imageDir); 111 113 BaseObject* load(const char* fileName, ResourcePriority prio = RP_NO, 112 114 void* param1 = NULL, void* param2 = NULL, void* param3 = NULL); … … 120 122 121 123 122 // utility functions of this class124 // utility functions for handling files in and around the data-directory 123 125 static bool isDir(const char* directory); 124 126 static bool isFile(const char* fileName); … … 130 132 131 133 static const char* ResourceTypeToChar(ResourceType type); 134 132 135 133 136 private:
Note: See TracChangeset
for help on using the changeset viewer.