Index: trunk/src/lib/util/loading/resource_manager.cc
===================================================================
--- trunk/src/lib/util/loading/resource_manager.cc	(revision 7474)
+++ trunk/src/lib/util/loading/resource_manager.cc	(revision 7661)
@@ -17,5 +17,5 @@
 
 #include "util/loading/resource_manager.h"
-
+#include "file.h"
 #include "substring.h"
 #include "debug.h"
@@ -60,5 +60,4 @@
 
   this->dataDir = "./";
-  this->_cwd = "";
   this->tryDataDir("./data");
 }
@@ -87,14 +86,11 @@
 bool ResourceManager::setDataDir(const std::string& dataDir)
 {
-  std::string realDir = ResourceManager::homeDirCheck(dataDir);
-  if (isDir(realDir))
-  {
-    if (dataDir[dataDir.size()-1] == '/' || dataDir[dataDir.size()-1] == '\\')
+  File dataDirectory(dataDir);
+  if (dataDirectory.isDirectory())
+  {
+    this->dataDir = dataDirectory.name();
+
+    if (dataDir[dataDir.size()-1] != '/' && dataDir[dataDir.size()-1] != '\\')
     {
-      this->dataDir = realDir;
-    }
-    else
-    {
-      this->dataDir = realDir;
       this->dataDir += '/';
     }
@@ -103,5 +99,5 @@
   else
   {
-    PRINTF(1)("%s is not a Directory, and can not be the Data Directory, leaving as %s \n", realDir.c_str(), this->dataDir.c_str());
+    PRINTF(1)("%s is not a Directory, and can not be the Data Directory, leaving as %s \n", dataDir.c_str(), this->dataDir.c_str());
     return false;
   }
@@ -116,14 +112,11 @@
 bool ResourceManager::tryDataDir(const std::string& dataDir)
 {
-  std::string realDir = ResourceManager::homeDirCheck(dataDir);
-  if (isDir(realDir))
-  {
-    if (dataDir[dataDir.size()-1] == '/' || dataDir[dataDir.size()-1] == '\\')
+  File dataDirectory(dataDir);
+  if (dataDirectory.isDirectory())
+  {
+    this->dataDir = dataDirectory.name();
+
+    if (dataDir[dataDir.size()-1] != '/' && dataDir[dataDir.size()-1] != '\\')
     {
-      this->dataDir = realDir;
-    }
-    else
-    {
-      this->dataDir = realDir;
       this->dataDir += '/';
     }
@@ -140,14 +133,13 @@
 bool ResourceManager::verifyDataDir(const std::string& fileInside)
 {
-  bool retVal;
-  if (!isDir(this->dataDir))
-  {
-    PRINTF(1)("%s is not a directory\n", this->dataDir.c_str());
+  File dataDirectory(this->dataDir);
+  if (!dataDirectory.isDirectory())
+  {
+    PRINTF(1)("'%s' is not a directory\n", this->dataDir.c_str());
     return false;
   }
 
-  std::string testFile = this->dataDir + fileInside;
-  retVal = isFile(testFile);
-  return retVal;
+  File testFile(this->dataDir + fileInside);
+  return testFile.isFile();
 }
 
@@ -161,16 +153,11 @@
 bool ResourceManager::addImageDir(const std::string& imageDir)
 {
-  std::string newDir;
-  if (imageDir[imageDir.size()-1] == '/' || imageDir[imageDir.size()-1] == '\\')
-  {
-    newDir = imageDir;
-  }
-  else
-  {
-    newDir = imageDir;
+  std::string newDir = imageDir;
+  if (imageDir[imageDir.size()-1] != '/' && imageDir[imageDir.size()-1] != '\\')
+  {
     newDir += '/';
   }
   // check if the param is a Directory
-  if (isDir(newDir))
+  if (File(newDir).isDirectory())
   {
     // check if the Directory has been added before
@@ -381,5 +368,5 @@
         tmpResource->param[0] = 1.0f;
 
-      if(ResourceManager::isFile(fullName))
+      if(File(fullName).isFile())
         tmpResource->pointer = new OBJModel(fullName, tmpResource->param[0].getFloat());
       else
@@ -407,5 +394,5 @@
       break;
     case MD2:
-      if(ResourceManager::isFile(fullName))
+      if(File(fullName).isFile())
       {
         tmpResource->param[0] = param0;
@@ -425,5 +412,5 @@
         tmpResource->param[0] = FONT_DEFAULT_RENDER_SIZE;
 
-      if(isFile(fullName))
+      if(File(fullName).isFile())
         tmpResource->pointer = new Font(fullName, (unsigned int) tmpResource->param[0].getInt());
       else
@@ -433,9 +420,9 @@
 #ifndef NO_AUDIO
     case WAV:
-      if(isFile(fullName))
+      if(File(fullName).isFile())
         tmpResource->pointer = new OrxSound::SoundBuffer(fullName);
       break;
     case OGG:
-      if (isFile(fullName))
+      if (File(fullName).isFile())
         tmpResource->pointer = new OrxSound::OggPlayer(fullName);
       break;
@@ -447,5 +434,5 @@
       else
         tmpResource->param[0] = GL_TEXTURE_2D;
-      if(isFile(fullName))
+      if(File(fullName).isFile())
       {
         PRINTF(4)("Image %s resides to %s\n", fileName, fullName);
@@ -458,5 +445,5 @@
         {
           std::string imgName = *imageDir + fileName;
-          if(isFile(imgName))
+          if(File(imgName).isFile())
           {
             PRINTF(4)("Image %s resides to %s\n", fileName, imgName);
@@ -472,5 +459,5 @@
 #ifndef NO_SHADERS
     case SHADER:
-      if(ResourceManager::isFile(fullName))
+      if(File(fullName).isFile())
       {
         if (param0 != MT_NULL)
@@ -478,5 +465,5 @@
           MultiType param = param0; /// HACK
           std::string secFullName = ResourceManager::getFullName(param.getCString());
-          if (ResourceManager::isFile(secFullName))
+          if (File(secFullName).isFile())
           {
             tmpResource->param[0] = secFullName;
@@ -750,136 +737,4 @@
 
 /**
- * @brief Checks if it is a Directory
- * @param directoryName the Directory to check for
- * @returns true if it is a directory/symlink false otherwise
-*/
-bool ResourceManager::isDir(const std::string& directoryName)
-{
-  std::string tmpDirName = directoryName;
-  struct stat status;
-
-  // checking for the termination of the string given. If there is a "/" at the end cut it away
-  if (directoryName[directoryName.size()-1] == '/' ||
-      directoryName[directoryName.size()-1] == '\\')
-  {
-    tmpDirName.erase(tmpDirName.size()-1);
-  }
-
-  if(!stat(tmpDirName.c_str(), &status))
-  {
-    if (status.st_mode & (S_IFDIR
-#ifndef __WIN32__
-                          | S_IFLNK
-#endif
-                         ))
-    {
-      return true;
-    }
-    else
-      return false;
-  }
-  else
-    return false;
-}
-
-/**
- * @brief Checks if the file is either a Regular file or a Symlink
- * @param fileName the File to check for
- * @returns true if it is a regular file/symlink, false otherwise
-*/
-bool ResourceManager::isFile(const std::string& fileName)
-{
-  if (fileName.empty())
-    return false;
-  std::string tmpFileName = ResourceManager::homeDirCheck(fileName);
-  // actually checks the File
-  struct stat status;
-  if (!stat(tmpFileName.c_str(), &status))
-  {
-    if (status.st_mode & (S_IFREG
-#ifndef __WIN32__
-                          | S_IFLNK
-#endif
-                         ))
-    {
-      return true;
-    }
-    else
-      return false;
-  }
-  else
-    return false;
-}
-
-/**
- * @brief touches a File on the disk (thereby creating it)
- * @param fileName The file to touch
-*/
-bool ResourceManager::touchFile(const std::string& fileName)
-{
-  std::string tmpName = ResourceManager::homeDirCheck(fileName);
-  if (tmpName.empty())
-    return false;
-  FILE* stream;
-  if( (stream = fopen (tmpName.c_str(), "w")) == NULL)
-  {
-    PRINTF(1)("could not open %s fro writing\n", fileName.c_str());
-    return false;
-  }
-  fclose(stream);
-}
-
-/**
- * @brief deletes a File from disk
- * @param fileName the File to delete
-*/
-bool ResourceManager::deleteFile(const std::string& fileName)
-{
-  std::string tmpName = ResourceManager::homeDirCheck(fileName);
-  unlink(tmpName.c_str());
-}
-
-/**
- * @param name the Name of the file to check
- * @returns The name of the file, including the HomeDir
- */
-std::string ResourceManager::homeDirCheck(const std::string& name)
-{
-  if (name.size() >= 2 && name[0] == '~' && name[1] == '/')
-  {
-    std::string homeDir;
-    std::string newName = name.substr(1);
-#ifdef __WIN32__
-    homeDir = getenv("USERPROFILE");
-#else
-    homeDir = getenv("HOME");
-#endif
-    return homeDir + newName;
-  }
-  else
-    return name;
-}
-
-/**
- * @param name the relative name of the File/Directory.
- * @returns a new std::string with the name in abs-dir-format
- */
-std::string ResourceManager::getAbsDir(const std::string& name)
-{
-  if (name.empty())
-    return "";
-  std::string retName = name;
-  if (strncmp(name.c_str(), "/", 1))
-  {
-    if (name[0] == '.' && name[1] != '.')
-      retName.erase(0);
-    const std::string& absDir = ResourceManager::cwd();
-    retName = absDir + retName;
-  }
-  return retName;
-}
-
-
-/**
  * @param fileName the Name of the File to check
  * @returns The full name of the file, including the DataDir, and NULL if the file does not exist
@@ -892,32 +747,8 @@
 
   std::string retName = ResourceManager::getInstance()->getDataDir() +fileName;
-  if (ResourceManager::isFile(retName) || ResourceManager::isDir(retName))
+  if (File(retName).isFile() || File(retName).isDirectory())
     return retName;
   else
     return "";
-}
-
-#ifdef __unix__
-  #include <unistd.h>
-#elif __WIN32__ || _MS_DOS_
-  #include <dir.h>
-#else
-  #include <direct.h> /* Visual C++ */
-#endif
-/**
- * @returns the Current Woring Directory
- */
-const std::string& ResourceManager::cwd()
-{
-  if (ResourceManager::getInstance()->_cwd.empty())
-  {
-    char cwd[1024];
-    char* errorCode = getcwd(cwd, 1024);
-    if (errorCode == 0)
-      return ResourceManager::getInstance()->_cwd;
-
-    ResourceManager::getInstance()->_cwd = cwd;
-  }
-  return ResourceManager::getInstance()->_cwd;
 }
 
@@ -936,5 +767,5 @@
   std::string checkFile = ResourceManager::getInstance()->getDataDir() + fileName;
 
-  if (ResourceManager::isFile(checkFile) || ResourceManager::isDir(checkFile))
+  if (File(checkFile).exists())
     retVal = true;
   else
Index: trunk/src/lib/util/loading/resource_manager.h
===================================================================
--- trunk/src/lib/util/loading/resource_manager.h	(revision 7474)
+++ trunk/src/lib/util/loading/resource_manager.h	(revision 7661)
@@ -21,6 +21,7 @@
 
 #include "base_object.h"
+#include "file.h"
+
 #include "multi_type.h"
-
 #include <vector>
 
@@ -130,13 +131,6 @@
 
   // utility functions for handling files in and around the data-directory
-  static bool isDir(const std::string& directory);
-  static bool isFile(const std::string& fileName);
-  static bool touchFile(const std::string& fileName);
-  static bool deleteFile(const std::string& fileName);
-  static std::string homeDirCheck(const std::string& fileName);
   static std::string getFullName(const std::string& fileName);
   static bool isInDataDir(const std::string& fileName);
-  static std::string getAbsDir(const std::string& fileName);
-  static const std::string& cwd();
 
   static const char* ResourceTypeToChar(ResourceType type);
@@ -151,5 +145,4 @@
   static ResourceManager*    singletonRef;       //!< singleton Reference
 
-  std::string                _cwd;               //!< The currend Working directory.
   std::string                dataDir;            //!< The Data Directory, where all relevant Data is stored.
   std::vector<std::string>   imageDirs;          //!< A list of directories in which images are stored.
