Index: branches/qt_gui/src/lib/util/file.cc
===================================================================
--- branches/qt_gui/src/lib/util/file.cc	(revision 7615)
+++ branches/qt_gui/src/lib/util/file.cc	(revision 7616)
@@ -18,4 +18,8 @@
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <stdio.h>
+
+#include <iostream>
+#include <fstream>
 
 #ifdef __unix__
@@ -27,125 +31,186 @@
 #endif
 
-
-
-File::File()
+#include <cassert>
+
+
+File::File(const std::string& fileName)
+{
+  this->_name = fileName;
+  File::homeDirCheck(this->_name);
+  this->init();
+}
+
+File::File(const File& file)
+{
+  this->_name = file._name;
+}
+
+File::~File()
+{
+  if (this->_status)
+    delete this->_status;
+  if (this->_handle)
+    assert(0);
+}
+
+/**
+ * @brief initializes the File
+ *
+ * Stats the File, looks if it exists and sets the hadle to 0
+ */
+void File::init()
+{
+  this->_handle = 0;
+
+  this->_status = new struct stat;
+  if (stat(this->_name.c_str(), this->_status))
+  {
+    delete this->_status;
+    this->_status = NULL;
+  }
+}
+
+bool File::open(OpenMode mode)
 {
 #warning implement
 }
 
-File::File(const std::string& fileName)
+bool File::close()
 {
 #warning implement
 }
 
-File::File(const File& file)
-{
-#warning implement
-}
-
-File::~File()
-{
-#warning implement
-}
-
-bool File::open(OpenMode mode)
-{
-#warning implement
-}
-
-bool File::close()
-{
-#warning implement
-}
-
 int File::handle()
 {
-#warning implement
+  return this->_handle;
 }
 
 bool File::exists()
 {
-#warning implement
+  return (this->_status != NULL);
 }
 
 bool File::isLink()
 {
-#warning implement
+#ifndef __WIN32__
+  return (this->_status != NULL && this->_status->st_mode & (S_IFLNK));
+#else
+  return false;
+#endif
 }
 // only on UNIX
+
 bool File::isFile()
 {
-#warning implement
-}
-
+  return (this->_status != NULL && this->_status->st_mode & (S_IFREG));
+}
+
+/**
+ * @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 File::isDirectory()
 {
-  std::string tmpDirName = this->_name;
-  struct stat status;
-
   // checking for the termination of the string given. If there is a "/" at the end cut it away
-  if (this->_name[this->_name.size()-1] == '/' ||
-      this->_name[this->_name.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
+  //if (this->_name[this->_name.size()-1] == '/' ||
+  //    this->_name[this->_name.size()-1] == '\\')
+  //{
+  //  tmpDirName.erase(tmpDirName.size()-1);
+  //}
+  return (this->_status != NULL && this->_status->st_mode & (S_IFDIR));
+}
+
+
+/// FIXME NEXT THREE FUNCTIONS
+bool File::isReadeable()
+{
+#ifndef __WIN32__
+  return (this->_status != NULL && this->_status->st_mode & (S_IRUSR));
+#else
+  return (this->_status != NULL);
+#endif
+}
+
+bool File::isWriteable()
+{
+#ifndef __WIN32__
+  return (this->_status != NULL && this->_status->st_mode & (S_IWUSR));
+#else
+  return (this->_status != NULL);
+#endif
+}
+bool File::isExecutable()
+{
+#ifndef __WIN32__
+  return (this->_status != NULL && this->_status->st_mode & (S_IXUSR));
+#else
+  return (this->_status != NULL);
+#endif
+}
+
+
+bool File::copy(const File& destination)
+{
+  char ch;
+  std::ifstream iFile(this->_name.c_str());
+  std::ofstream oFile(destination.name().c_str());
+  while (iFile.get(ch))
+  {
+    oFile.put(ch);
+  }
+}
+
+bool File::rename(const File& destination)
+{
+  if (!std::rename(this->_name.c_str(), destination.name().c_str()))
+  {
+    this->close();
+    delete this->_status;
+    this->_status = NULL;
+    this->_name = destination.name();
+    this->init();
+
+    return true;
+  }
+  return false;
+}
+
+bool File::touch()
+{
+  FILE* stream;
+  if( (stream = fopen (this->_name.c_str(), "w")) == NULL)
+  {
+    std::cout << "could not touch '" << this->_name << "' for writing\n";
     return false;
-}
-
-bool File::isReadeable()
-{
-
-#warning implement
-}
-
-bool File::isWriteable()
-{
-#warning implement
-}
-bool File::isExecutable()
-{
-#warning implement
-}
-
-
-bool File::copy(const File& destination)
-{
-#warning implement
-}
-bool File::rename(const File& destination)
-{
-#warning implement
-}
-bool File::touch()
-{
-#warning implement
-}
+  }
+  fclose(stream);
+  return true;
+}
+
 bool File::remove()
 {
-#warning implement
+  unlink(this->_name.c_str());
+  delete this->_status;
+  this->_status = NULL;
+  /// FIXME HANDLE
 }
 
 void File::relToAbs(std::string& fileName)
 {
-#warning implement
-}
+  if (fileName.empty())
+    return ;
+  if (fileName[0] !=  '/')
+  {
+    if (fileName[0] == '.' && fileName[1] != '.')
+      fileName.erase(0);
+    fileName = File::cwd() + fileName;
+  }
+}
+
 void File::absToRel(std::string& fileName)
 {
-#warning implement
+  if (fileName.find(cwd()) == 0)
+    fileName.replace(0, File::cwd().size(), ".");
 }
 
@@ -173,4 +238,17 @@
 
 
+void File::homeDirCheck(std::string& fileName)
+{
+  if (fileName.size() < 2 || fileName[0] != '~' || fileName[1] != '/')
+    return;
+  std::string homeDir;
+#ifdef __WIN32__
+    homeDir = getenv("USERPROFILE");
+#else
+    homeDir = getenv("HOME");
+#endif
+    fileName = homeDir + fileName.substr(1);
+}
+
 
 #include "file.h"
Index: branches/qt_gui/src/lib/util/file.h
===================================================================
--- branches/qt_gui/src/lib/util/file.h	(revision 7615)
+++ branches/qt_gui/src/lib/util/file.h	(revision 7616)
@@ -9,4 +9,5 @@
 
 #include <string>
+typedef struct stat;
 
 class File
@@ -22,5 +23,4 @@
 
 public:
-  File();
   File(const std::string& fileName);
   File(const File& file);
@@ -30,4 +30,7 @@
   virtual bool close();
   int handle();
+
+  /** @returns the FileName of this File */
+  const std::string& name() const { return this->_name; };
 
   bool exists();
@@ -50,11 +53,15 @@
 
   private:
+    void init();
+    bool statFile;
     void homeDirCheck(std::string& fileName);
 
   private:
     int                 _handle;          //!< The FileHandle (if set).
-    std::string         _name;             //!< The Name of the File.
+    std::string         _name;            //!< The Name of the File.
+    stat*               _status;          //!< The Stat of the File.
 
     static std::string  _cwd;             //!< The currend Working directory.
+
 };
 
Index: branches/qt_gui/src/lib/util/loading/resource_manager.cc
===================================================================
--- branches/qt_gui/src/lib/util/loading/resource_manager.cc	(revision 7615)
+++ branches/qt_gui/src/lib/util/loading/resource_manager.cc	(revision 7616)
@@ -86,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 += '/';
     }
@@ -102,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;
   }
@@ -115,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 += '/';
     }
@@ -139,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();
 }
 
@@ -160,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
@@ -380,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
@@ -406,5 +394,5 @@
       break;
     case MD2:
-      if(ResourceManager::isFile(fullName))
+      if(File(fullName).isFile())
       {
         tmpResource->param[0] = param0;
@@ -424,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
@@ -432,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;
@@ -446,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);
@@ -457,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);
@@ -471,5 +459,5 @@
 #ifndef NO_SHADERS
     case SHADER:
-      if(ResourceManager::isFile(fullName))
+      if(File(fullName).isFile())
       {
         if (param0 != MT_NULL)
@@ -477,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;
@@ -749,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 = File::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
@@ -891,5 +747,5 @@
 
   std::string retName = ResourceManager::getInstance()->getDataDir() +fileName;
-  if (ResourceManager::isFile(retName) || ResourceManager::isDir(retName))
+  if (File(retName).isFile() || File(retName).isDirectory())
     return retName;
   else
@@ -911,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: branches/qt_gui/src/lib/util/loading/resource_manager.h
===================================================================
--- branches/qt_gui/src/lib/util/loading/resource_manager.h	(revision 7615)
+++ branches/qt_gui/src/lib/util/loading/resource_manager.h	(revision 7616)
@@ -21,6 +21,7 @@
 
 #include "base_object.h"
+#include "file.h"
+
 #include "multi_type.h"
-
 #include <vector>
 
@@ -130,12 +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 char* ResourceTypeToChar(ResourceType type);
