Changeset 7174 in orxonox.OLD for branches/shared_lib/src/util/loading/resource_manager.cc
- Timestamp:
- Feb 21, 2006, 10:48:52 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/shared_lib/src/util/loading/resource_manager.cc
r7059 r7174 62 62 strcpy(this->dataDir, "./"); 63 63 this->tryDataDir("./data"); 64 65 this->_cwd = NULL; 64 66 } 65 67 … … 86 88 87 89 delete[] this->dataDir; 88 90 if (this->_cwd) 91 delete[] this->_cwd; 89 92 ResourceManager::singletonRef = NULL; 90 93 } … … 984 987 985 988 /** 989 * @param name the relative name of the File/Directory. 990 * @returns a new char* with the name in abs-dir-format 991 */ 992 char* ResourceManager::getAbsDir(const char* name) 993 { 994 if (name == NULL) 995 return NULL; 996 char* retName; 997 if (strncmp(name, "/", 1)) 998 { 999 if (*name == '.' && *(name+1) != '.') 1000 name++; 1001 const char* absDir = ResourceManager::cwd(); 1002 retName = new char[strlen(absDir)+strlen(name)+1]; 1003 sprintf(retName, "%s%s", absDir, name); 1004 } 1005 else 1006 { 1007 retName = new char[strlen(name)+1]; 1008 strcpy(retName, name); 1009 } 1010 return retName; 1011 } 1012 1013 1014 /** 986 1015 * @param fileName the Name of the File to check 987 1016 * @returns The full name of the file, including the DataDir, and NULL if the file does not exist … … 1003 1032 return NULL; 1004 1033 } 1034 } 1035 1036 #ifdef __unix__ 1037 #include <unistd.h> 1038 #elif __WIN32__ || _MS_DOS_ 1039 #include <dir.h> 1040 #else 1041 #include <direct.h> /* Visual C++ */ 1042 #endif 1043 /** 1044 * @returns the Current Woring Directory 1045 */ 1046 const char* ResourceManager::cwd() 1047 { 1048 if (ResourceManager::getInstance()->_cwd == NULL) 1049 { 1050 char cwd[1024]; 1051 char* errno = getcwd(cwd, 1024); 1052 if (errno == 0) 1053 return NULL; 1054 1055 ResourceManager::getInstance()->_cwd = new char[strlen(cwd)+1]; 1056 strcpy(ResourceManager::getInstance()->_cwd, cwd); 1057 } 1058 return ResourceManager::getInstance()->_cwd; 1005 1059 } 1006 1060
Note: See TracChangeset
for help on using the changeset viewer.