Changeset 3883 in orxonox.OLD for orxonox/trunk
- Timestamp:
- Apr 18, 2005, 11:03:16 PM (20 years ago)
- Location:
- orxonox/trunk/src/util
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/util/resource_manager.cc
r3869 r3883 39 39 { 40 40 this->setClassName ("ResourceManager"); 41 this->dataDir = "./"; 41 this->dataDir = NULL; 42 this->setDataDir("./"); 42 43 this->imageDirs = new tList<char>(); 43 44 this->resourceList = new tList<Resource>(); … … 84 85 \param dataDir the DataDirectory. 85 86 */ 86 bool ResourceManager::setDataDir(c har* dataDir)87 bool ResourceManager::setDataDir(const char* dataDir) 87 88 { 88 89 if (isDir(dataDir)) 89 90 { 91 delete this->dataDir; 90 92 this->dataDir = new char[strlen(dataDir)+1]; 91 93 strcpy(this->dataDir, dataDir); … … 93 95 else 94 96 { 95 PRINTF(1)("%s is not a Directory, and can not be the Data Directory \n",dataDir);97 PRINTF(1)("%s is not a Directory, and can not be the Data Directory, leaving as %s \n", dataDir, this->dataDir); 96 98 } 97 99 } … … 490 492 bool ResourceManager::isDir(const char* directoryName) 491 493 { 494 char* tmpDirName = NULL; 492 495 struct stat status; 493 stat(directoryName, &status); 494 if (status.st_mode & (S_IFDIR 496 497 // checking for the termination of the string given. If there is a "/" at the end cut it away 498 if (directoryName[strlen(directoryName)-1] == '/') 499 { 500 tmpDirName = new char[strlen(directoryName)+1]; 501 strncpy(tmpDirName, directoryName, strlen(directoryName)-1); 502 tmpDirName[strlen(directoryName)-1] = '\0'; 503 } 504 else 505 { 506 tmpDirName = new char[strlen(directoryName)+1]; 507 strcpy(tmpDirName, directoryName); 508 } 509 510 stat(tmpDirName, &status); 511 if (status.st_mode & (S_IFDIR 495 512 #ifndef __WIN32__ 496 513 | S_IFLNK 497 514 #endif 498 515 )) 499 return true; 500 else 501 return false; 516 { 517 delete tmpDirName; 518 return true; 519 } 520 else 521 { 522 delete tmpDirName; 523 return false; 524 } 502 525 } 503 526 -
orxonox/trunk/src/util/resource_manager.h
r3869 r3883 65 65 virtual ~ResourceManager(); 66 66 67 bool setDataDir(c har* dataDir);67 bool setDataDir(const char* dataDir); 68 68 bool addImageDir(char* imageDir); 69 69 void* load(const char* fileName, ResourcePriority prio = RP_NO,
Note: See TracChangeset
for help on using the changeset viewer.