Changeset 5335 in orxonox.OLD for trunk/src/util
- Timestamp:
- Oct 9, 2005, 1:27:58 AM (19 years ago)
- Location:
- trunk/src/util
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/util/resource_manager.cc
r5334 r5335 60 60 this->dataDir = NULL; 61 61 this->setDataDir("./"); 62 this->imageDirs = new tList<char> ();63 this->resourceList = new tList<Resource> ();62 this->imageDirs = new tList<char>; 63 this->resourceList = new tList<Resource>; 64 64 } 65 65 … … 105 105 { 106 106 delete[] this->dataDir; 107 this->dataDir = new char[strlen(realDir)+1]; 108 strcpy(this->dataDir, realDir); 107 if (dataDir[strlen(dataDir)-1] == '/' || dataDir[strlen(dataDir)-1] == '\\') 108 { 109 this->dataDir = new char[strlen(realDir)+1]; 110 strcpy(this->dataDir, realDir); 111 } 112 else 113 { 114 this->dataDir = new char[strlen(realDir)+2]; 115 strcpy(this->dataDir, realDir); 116 this->dataDir[strlen(realDir)] = '/'; 117 this->dataDir[strlen(realDir)+1] = '\0'; 118 } 109 119 delete[] realDir; 110 120 return true; … … 147 157 bool ResourceManager::addImageDir(const char* imageDir) 148 158 { 159 if (imageDir == NULL) 160 return false; 161 162 char* newDir; 163 if (imageDir[strlen(imageDir)-1] == '/' || imageDir[strlen(imageDir)-1] == '\\') 164 { 165 newDir = new char[strlen(imageDir)+1]; 166 strcpy(newDir, imageDir); 167 } 168 else 169 { 170 newDir = new char[strlen(imageDir)+2]; 171 strcpy(newDir, imageDir); 172 newDir[strlen(imageDir)] = '/'; 173 newDir[strlen(imageDir)+1] = '\0'; 174 } 149 175 // check if the param is a Directory 150 if (isDir( imageDir))176 if (isDir(newDir)) 151 177 { 152 178 // check if the Directory has been added before … … 155 181 while(tmpDir) 156 182 { 157 if (!strcmp(tmpDir, imageDir))183 if (!strcmp(tmpDir, newDir)) 158 184 { 159 PRINTF(4)("Path %s already loaded\n", imageDir); 185 PRINTF(3)("Path %s already loaded\n", newDir); 186 delete[] newDir; 160 187 delete tmpImageDirs; 161 188 return true; … … 166 193 167 194 // adding the directory to the List 168 tmpDir = new char[strlen(imageDir)+1]; 169 strcpy(tmpDir, imageDir); 170 this->imageDirs->add(tmpDir); 195 this->imageDirs->add(newDir); 171 196 return true; 172 197 } 173 198 else 174 199 { 175 PRINTF(1)("%s is not a Directory, and can not be added to the Paths of Images\n", dataDir); 200 PRINTF(1)("%s is not a Directory, and can not be added to the Paths of Images\n", newDir); 201 delete[] newDir; 176 202 return false; 177 203 } … … 660 686 directoryName[strlen(directoryName)-1] == '\\') 661 687 { 662 tmpDirName = new char[strlen(directoryName) +1];688 tmpDirName = new char[strlen(directoryName)]; 663 689 strncpy(tmpDirName, directoryName, strlen(directoryName)-1); 664 690 tmpDirName[strlen(directoryName)-1] = '\0'; … … 800 826 char* ResourceManager::getFullName(const char* fileName) 801 827 { 802 if (fileName == NULL )828 if (fileName == NULL || ResourceManager::getInstance()->getDataDir() == NULL) 803 829 return NULL; 804 830 … … 813 839 return NULL; 814 840 } 841 } 842 843 844 /** 845 * checks wether a file is in the DataDir. 846 * @param fileName the File to check if it is in the Data-Dir structure. 847 * @returns true if the file exists, false otherwise 848 */ 849 bool ResourceManager::isInDataDir(const char* fileName) 850 { 851 if (fileName == NULL || ResourceManager::getInstance()->getDataDir() == NULL) 852 return false; 853 854 bool retVal = false; 855 char* checkFile = new char[strlen(ResourceManager::getInstance()->getDataDir()) 856 + strlen(fileName) + 1]; 857 sprintf(checkFile, "%s%s", ResourceManager::getInstance()->getDataDir(), fileName); 858 859 if (ResourceManager::isFile(checkFile) || ResourceManager::isDir(checkFile)) 860 retVal = true; 861 else 862 retVal = false; 863 delete[] checkFile; 864 return retVal; 815 865 } 816 866 -
trunk/src/util/resource_manager.h
r5323 r5335 108 108 109 109 bool checkDataDir(const char* fileInside); 110 110 bool addImageDir(const char* imageDir); 111 111 BaseObject* load(const char* fileName, ResourcePriority prio = RP_NO, 112 112 void* param1 = NULL, void* param2 = NULL, void* param3 = NULL); … … 127 127 static char* homeDirCheck(const char* fileName); 128 128 static char* getFullName(const char* fileName); 129 static bool isInDataDir(const char* fileName); 129 130 130 131 static const char* ResourceTypeToChar(ResourceType type); -
trunk/src/util/track/track_manager.cc
r5313 r5335 900 900 * @param count The count of Paths to join. 901 901 * @param trackIDs an Array with the trackID's to join 902 903 \see void TrackManager::join(unsigned int count, ...)902 * 903 * @see void TrackManager::join(unsigned int count, ...) 904 904 */ 905 905 void TrackManager::joinV(unsigned int count, int* trackIDs)
Note: See TracChangeset
for help on using the changeset viewer.