Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Feb 21, 2006, 10:48:52 PM (19 years ago)
Author:
bensch
Message:

orxonox/dylib: now the dylibLoader should work

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/shared_lib/src/util/loading/resource_manager.cc

    r7059 r7174  
    6262  strcpy(this->dataDir, "./");
    6363  this->tryDataDir("./data");
     64
     65  this->_cwd = NULL;
    6466}
    6567
     
    8688
    8789  delete[] this->dataDir;
    88 
     90  if (this->_cwd)
     91    delete[] this->_cwd;
    8992  ResourceManager::singletonRef = NULL;
    9093}
     
    984987
    985988/**
     989 * @param name the relative name of the File/Directory.
     990 * @returns a new char* with the name in abs-dir-format
     991 */
     992char* 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/**
    9861015 * @param fileName the Name of the File to check
    9871016 * @returns The full name of the file, including the DataDir, and NULL if the file does not exist
     
    10031032    return NULL;
    10041033  }
     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 */
     1046const 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;
    10051059}
    10061060
Note: See TracChangeset for help on using the changeset viewer.