Index: trunk/src/lib/util/directory.cc
===================================================================
--- trunk/src/lib/util/directory.cc	(revision 7661)
+++ trunk/src/lib/util/directory.cc	(revision 7661)
@@ -0,0 +1,153 @@
+/*
+   orxonox - the future of 3D-vertical-scrollers
+
+   Copyright (C) 2004 orx
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+### File Specific:
+   main-programmer: Benjamin Grauer
+   co-programmer: ...
+
+   Borrowed the Main code from 'Bart Vanhauwaert' (license below)
+   and adopted it to my likings.
+*/
+
+/**
+ * Copyright (C) 2002 Bart Vanhauwaert
+ *
+ * Permission to use, copy, modify, distribute and sell this software
+ * for any purpose is hereby granted without fee. This license
+ * includes (but is not limited to) standalone compilation or as part
+ * of a larger project.
+ *
+ * This software is provided "as is" without express or implied warranty.
+ *
+ * For a full statement on warranty and terms and conditions for
+ * copying, distribution and modification, please see the comment block
+ * at the end of this file.
+ *
+ * Version 1
+ *
+ */
+
+#include "directory.h"
+
+#if not defined (__WIN32__)
+ #include <sys/stat.h>
+ #include <sys/types.h>
+#endif
+Directory::Directory(const std::string& directoryName)
+  : File(directoryName), willfail(false)
+{
+  this->handle = 0;
+  this->willfail = true;
+}
+
+Directory::~Directory()
+{
+}
+
+bool Directory::open()
+{
+#if not defined(__WIN32__)
+  if (this->handle != NULL)
+    this->close();
+  this->handle = opendir(this->name().c_str());
+  if (!handle)
+    willfail = true;
+  else
+  {
+    willfail = false;
+    dirent* entry = readdir(handle);
+    if (entry)
+      current = entry->d_name;
+    else
+      willfail = true;
+  }
+#else
+    if (handle != INVALID_HANDLE_VALUE)
+      this->close();
+
+    // First check the attributes trying to access a non-Directory with
+    // FindFirstFile takes ages
+    DWORD attrs = GetFileAttributes(this->name().c_str());
+    if ( (attrs == 0xFFFFFFFF) || ((attrs && FILE_ATTRIBUTE_DIRECTORY) == 0) )
+    {
+      willfail = true;
+      return false;
+    }
+    std::string Full(this->name());
+    // Circumvent a problem in FindFirstFile with c:\\* as parameter
+    if ( (Full.length() > 0) && (Full[Full.length()-1] != '\\') )
+      Full += "\\";
+    WIN32_FIND_DATA entry;
+    handle = FindFirstFile( (Full+"*").c_str(), &entry);
+    if (handle == INVALID_HANDLE_VALUE)
+    {
+      willfail = true;
+      return false;
+    }
+    else
+    {
+      willfail = false;
+      current = entry.cFileName;
+      return true;
+    }
+#endif
+
+}
+
+bool Directory::close()
+{
+#if not defined(__WIN32__)
+  if (this->handle != NULL)
+    closedir(handle);
+  this->handle = NULL;
+#else
+  if (handle != INVALID_HANDLE_VALUE)
+    FindClose(handle);
+    handle = 0;
+#endif
+  this->willfail = true;
+  this->current = "";
+  return true;
+}
+
+
+
+std::string Directory::next()
+{
+#if not defined(__WIN32__)
+  std::string prev(current);
+  dirent* entry = readdir(handle);
+  if (entry)
+    current = entry->d_name;
+  else
+    willfail = true;
+  return prev;
+
+#else
+  std::string prev = current;
+  WIN32_FIND_DATA entry;
+  int ok = FindNextFile(handle, &entry);
+  if (!ok)
+    willfail = true;
+  else
+    current = entry.cFileName;
+  return current;
+#endif
+}
+
+
+bool Directory::create()
+{
+#if not defined (__WIN32__)
+  return (!mkdir(this->name().c_str(), 0777));
+#else
+  return (!CreateDirectory(this->name().c_str(), NULL));
+#endif
+}
Index: trunk/src/lib/util/directory.h
===================================================================
--- trunk/src/lib/util/directory.h	(revision 7661)
+++ trunk/src/lib/util/directory.h	(revision 7661)
@@ -0,0 +1,97 @@
+/*!
+ * @file directory.h
+ * @brief Definition of the Directory Handler class
+ */
+
+
+/**
+ * Copyright (C) 2002 Bart Vanhauwaert
+ *
+ * Permission to use, copy, modify, distribute and sell this software
+ * for any purpose is hereby granted without fee. This license
+ * includes (but is not limited to) standalone compilation or as part
+ * of a larger project.
+ *
+ * This software is provided "as is" without express or implied warranty.
+ *
+ * For a full statement on warranty and terms and conditions for
+ * copying, distribution and modification, please see the comment block
+ * at the end of this file.
+ *
+ * Version 1
+ *
+ */
+
+#ifndef __DIRECTORY_H_
+#define __DIRECTORY_H_
+
+#include "file.h"
+
+#if not defined (__WIN32__)
+ #include <sys/types.h>
+ #include <dirent.h>
+#else
+ #include <windows.h>
+ #include <winbase.h>
+#endif
+
+class Directory : public File
+{
+public:
+  Directory(const std::string& directoryName = "");
+  ~Directory();
+
+  virtual bool open();
+  virtual bool close();
+  operator void*() const { return willfail ? (void*)0:(void*)(-1); }
+
+  std::string next();
+
+  bool create();
+
+private:
+#if not defined(__WIN32__)
+  DIR* handle;
+#else
+  HANDLE    handle;
+#endif
+  bool willfail;
+  std::string current;
+};
+
+#endif /* __DIRECTORY_H_ */
+
+/**
+ *
+ * The "library", above, refers to the collection of software functions
+ * and/or data contained in this file, prepared so as to be conveniently
+ * compiled and linked with application programs (which use some of those
+ * functions and data) to form executables.
+ *
+ *                             NO WARRANTY
+ *
+ * 1. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+ * WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+ * EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+ * OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+ * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+ * LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+ * THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+ *
+ * 2. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+ * WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+ * AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+ * FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+ * CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+ * LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+ * RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+ * FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+ * SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGES.
+ *
+ * END OF TERMS AND CONDITIONS
+ *
+ */
+
Index: trunk/src/lib/util/file.cc
===================================================================
--- trunk/src/lib/util/file.cc	(revision 7661)
+++ trunk/src/lib/util/file.cc	(revision 7661)
@@ -0,0 +1,374 @@
+/*
+   orxonox - the future of 3D-vertical-scrollers
+
+   Copyright (C) 2004 orx
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+### File Specific:
+   main-programmer: Benjamin Grauer
+   co-programmer: ...
+*/
+
+#include "file.h"
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <stdio.h>
+
+#include <iostream>
+#include <fstream>
+
+#ifdef __unix__
+#include <unistd.h>
+#elif __WIN32__ || _MS_DOS_
+#include <dir.h>
+#else
+#include <direct.h>
+#endif
+
+#include <cassert>
+
+/**
+ * @brief default constructor.
+ */
+File::File()
+{
+  this->init();
+}
+
+/**
+ * @brief A File will be constructed and stated from a given FileName.
+ * @param fileName the FileName to load and stat.
+ */
+File::File(const std::string& fileName)
+{
+  this->init();
+  this->setFileName(fileName);
+}
+
+/**
+ * @brief A File will be constructed and stated from a given other File.
+ * @param file the File to get the Name from.
+ */
+File::File(const File& file)
+{
+  this->init();
+  this->setFileName(file.name());
+}
+
+File::~File()
+{
+  this->close();
+
+  if (this->_status)
+    delete this->_status;
+}
+
+
+/**
+ * @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 = NULL;
+}
+
+
+/**
+ * @brief sets a new File to apply to this File.
+ * @param fileName the Filename of the File to access.
+ */
+void File::setFileName(const std::string& fileName)
+{
+  this->close();
+  this->_name = fileName;
+  File::homeDirCheck(this->_name);
+  this->statFile();
+}
+
+/**
+ * @brief sets the file to the new File.
+ * @param fileName the FileName to set the File to.
+ * @returns this File.
+ */
+File& File::operator=(const std::string& fileName)
+{
+  this->setFileName(fileName);
+  return *this;
+}
+
+/**
+ * @brief sets the file to the new File.
+ * @param file the File to set the File to.
+ * @returns this File.
+ */
+File& File::operator=(const File& file)
+{
+  this->setFileName(file.name());
+  return *this;
+}
+
+/**
+ * @brief compares two files.
+ * @param fileName the File to compare against the stored one.
+ * @returns true if the filenames match.
+ */
+bool File::operator==(const std::string& fileName) const
+{
+  return (this->_name == fileName);
+}
+
+/**
+ * @brief compares two files.
+ * @param file the File to compare against the stored one.
+ * @returns true if the filenames match.
+ */
+bool File::operator==(const File& file) const
+{
+  return (this->_name == file.name());
+}
+
+
+/**
+ * @brief stats a File.
+ * Gathers information about the File, like permissions, and if it exists.
+ */
+void File::statFile()
+{
+  if (this->_status == NULL)
+    this->_status = new struct stat;
+  // Check the End of the FileName and chop away any \ and //
+  /*  std::string name = this->_name;
+    if (this->_name[this->_name.size()-1] == '/' ||
+        this->_name[this->_name.size()-1] == '\\')
+         name.resize(name.size()-1);*/
+  if (stat(this->_name.c_str(), this->_status))
+  {
+    delete this->_status;
+    this->_status = NULL;
+  }
+}
+
+bool File::open(OpenMode mode)
+{
+#warning implement
+}
+
+bool File::close()
+{
+#warning implement
+}
+
+bool File::exists() const
+{
+  return (this->_status != NULL);
+}
+
+/**
+ * @brief checks if the file is a Link (symlink/hardlink on UNIX)
+ * @returns true if the File is a Link, false otherwise (on windows always false)
+ */
+bool File::isLink() const
+{
+#ifndef __WIN32__
+  return (this->_status != NULL && this->_status->st_mode & (S_IFLNK));
+#else
+  return false;
+#endif
+}
+
+/**
+ * @brief checks if the File is a regular File
+ * @returns true if the File is a Regular file.
+ */
+bool File::isFile() const
+{
+  return (this->_status != NULL && this->_status->st_mode & (S_IFREG));
+}
+
+/**
+ * @brief Checks if the File is a Directory
+ * @returns true if it is a directory/symlink false otherwise
+ */
+bool File::isDirectory() const
+{
+  // 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);
+  //}
+  return (this->_status != NULL && this->_status->st_mode & (S_IFDIR));
+}
+
+
+/// FIXME NEXT THREE FUNCTIONS
+bool File::isReadeable() const
+{
+#ifndef __WIN32__
+  return (this->_status != NULL && this->_status->st_mode & (S_IRUSR));
+#else
+  return (this->_status != NULL);
+#endif
+}
+bool File::isWriteable() const
+{
+#ifndef __WIN32__
+  return (this->_status != NULL && this->_status->st_mode & (S_IWUSR));
+#else
+  return (this->_status != NULL);
+#endif
+}
+bool File::isExecutable() const
+{
+#ifndef __WIN32__
+  return (this->_status != NULL && this->_status->st_mode & (S_IXUSR));
+#else
+  return (this->_status != NULL);
+#endif
+}
+
+/**
+ * @brief copies the File to another File.
+ * @param destination the Destination File.
+ * @returns true on success, false otherwise.
+ */
+bool File::copy(const File& destination)
+{
+  if (*this == destination)
+  {
+    std::cout << "files are the Same '" << this->_name << "'\n";
+    return false;
+  }
+  char ch;
+  std::ifstream iFile(this->_name.c_str());
+  std::ofstream oFile(destination.name().c_str());
+  while (iFile.get(ch))
+  {
+    oFile.put(ch);
+  }
+}
+
+/**
+ * @brief renames the File (move)
+ * @param destination the Destination to move this file to.
+ * @returns true on success, false otherwise.
+ *
+ * if the File was opened, it will be closed throuh this function.
+ * The File will also be closed, if the File was not renamed.
+ */
+bool File::rename(const File& destination)
+{
+  this->close();
+
+  if (!std::rename(this->_name.c_str(), destination.name().c_str()))
+  {
+    this->_name = destination.name();
+    this->statFile();
+    return true;
+  }
+  return false;
+}
+
+/**
+ * @brief touches the File.
+ * @returns true if the file could have been touched. false otherwise.
+ *
+ * Touching a File means creating it.
+ */
+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;
+  }
+  fclose(stream);
+
+  this->statFile();
+  return true;
+}
+
+/**
+ * @brief delete the File on the Disk
+ * @returns true on success, false otherwise.
+ */
+bool File::remove()
+{
+  this->close();
+  unlink(this->_name.c_str());
+  delete this->_status;
+  this->_status = NULL;
+}
+
+/**
+ * @brief transforms a Relative path to an absolute one.
+ * @param fileName the Absolute Path.
+ */
+void File::relToAbs(std::string& relFileName)
+{
+  if (relFileName.empty())
+    return ;
+  if (relFileName[0] !=  '/')
+  {
+    if (relFileName[0] == '.' && relFileName[1] != '.')
+      relFileName.erase(0);
+    relFileName = File::cwd() + relFileName;
+  }
+}
+
+void File::absToRel(std::string& absFileName)
+{
+  if (absFileName.find(cwd()) == 0)
+    absFileName.replace(0, File::cwd().size(), ".");
+}
+
+
+std::string File::_cwd = "";
+
+/**
+ * @returns the Current Woring Directory
+ */
+const std::string& File::cwd()
+{
+  if (File::_cwd.empty())
+  {
+    char cwd[1024];
+    char* errorCode = getcwd(cwd, 1024);
+    if (errorCode == 0)
+      return File::_cwd;
+
+    File::_cwd = cwd;
+  }
+  return File::_cwd;
+}
+
+/**
+ * @brief check if fileName has the '~/` prepended.
+ * @returns the fileName in absolute coordinate.
+ */
+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: trunk/src/lib/util/file.h
===================================================================
--- trunk/src/lib/util/file.h	(revision 7661)
+++ trunk/src/lib/util/file.h	(revision 7661)
@@ -0,0 +1,76 @@
+/*!
+ * @file file.h
+ * @brief Definition of File Handler class
+ */
+
+#ifndef __FILE_H_
+#define __FILE_H_
+
+
+#include <string>
+typedef struct stat;
+
+//! A Class to Handle Files.
+class File
+{
+  public:
+  //! How the File should be opened.
+  typedef enum
+  {
+    ReadOnly,      //!< ReadOnly mode
+    WriteOnly,     //!< WriteOnly mode
+    ReadWrite,     //!< Read and Write mode together
+    Append,        //!< Append at the end.
+  } OpenMode;
+
+public:
+  File();
+  File(const std::string& fileName);
+  File(const File& file);
+  ~File();
+  void setFileName(const std::string& fileName);
+  File& operator=(const std::string& fileName);
+  File& operator=(const File& file);
+  bool operator==(const std::string& fileName) const;
+  bool operator==(const File& file) const;
+
+  virtual bool open(OpenMode mode);
+  virtual bool close();
+  int handle() const { return this->_handle; };
+
+  /** @returns the FileName of this File */
+  const std::string& name() const { return this->_name; };
+
+  bool exists() const;
+  bool isLink() const;
+  bool isFile() const ;
+  bool isDirectory() const;
+  bool isReadeable() const;
+  bool isWriteable() const;
+  bool isExecutable() const;
+
+
+  bool copy(const File& destination);
+  bool rename(const File& destination);
+  bool touch();
+  bool remove();
+
+  static void relToAbs(std::string& relFileName);
+  static void absToRel(std::string& absFileName);
+  static const std::string& cwd();
+
+  private:
+    void init();
+    void statFile();
+    void homeDirCheck(std::string& fileName);
+
+  private:
+    int                 _handle;          //!< The FileHandle (if set).
+    std::string         _name;            //!< The Name of the File.
+    stat*               _status;          //!< The Stat of the File.
+
+    static std::string  _cwd;             //!< The currend Working directory.
+
+};
+
+#endif /* __FILE_H_ */
Index: trunk/src/lib/util/loading/resource_manager.cc
===================================================================
--- trunk/src/lib/util/loading/resource_manager.cc	(revision 7477)
+++ 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 7477)
+++ 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.
Index: trunk/src/lib/util/osdir.h
===================================================================
--- trunk/src/lib/util/osdir.h	(revision 7477)
+++ 	(revision )
@@ -1,248 +1,0 @@
-/**
- * Copyright (C) 2002 Bart Vanhauwaert
- *
- * Permission to use, copy, modify, distribute and sell this software
- * for any purpose is hereby granted without fee. This license
- * includes (but is not limited to) standalone compilation or as part
- * of a larger project.
- *
- * This software is provided "as is" without express or implied warranty.
- *
- * For a full statement on warranty and terms and conditions for
- * copying, distribution and modification, please see the comment block
- * at the end of this file.
- *
- * Version 1
- *
- */
-
-#ifndef OSLINK_OSDIR_HEADER_H_
-#define OSLINK_OSDIR_HEADER_H_
-
-#if defined(unix) || defined(__unix) || defined(__unix__)
-#define OSLINK_OSDIR_POSIX
-#elif defined(_WIN32)
-#define OSLINK_OSDIR_WINDOWS
-#else
-#define OSLINK_OSDIR_NOTSUPPORTED
-#endif
-
-#include <string>
-
-#if defined(OSLINK_OSDIR_NOTSUPPORTED)
-
-namespace OS
-{
-  class Directory
-  {
-    public:
-      Directory(const std::string&) { }
-      bool open(const std::string&) {};
-      void close() {};
-
-      operator void*() const { return (void*)0; }
-      std::string next() { return ""; }
-  };
-}
-
-#elif defined(OSLINK_OSDIR_POSIX)
-
-#include <sys/types.h>
-#include <dirent.h>
-
-namespace OS
-{
-  class Directory
-  {
-    public:
-      Directory(const std::string& directoryName = "")
-          : willfail(false)
-      {
-        this->handle = NULL;
-        this->willfail = true;
-        this->open(directoryName);
-      }
-
-      ~Directory()
-      {
-        this->close();
-      }
-
-      bool open(const std::string& directoryName)
-      {
-        if (this->handle != NULL)
-          this->close();
-        this->handle = opendir(directoryName.c_str());
-        if (!handle)
-          willfail = true;
-        else
-        {
-          willfail = false;
-          dirent* entry = readdir(handle);
-          if (entry)
-            current = entry->d_name;
-          else
-            willfail = true;
-        }
-      }
-
-      void close()
-      {
-        if (this->handle != NULL)
-          closedir(handle);
-        this->handle = NULL;
-        this->willfail = true;
-        this->current = "";
-      }
-
-      operator void*() const
-      {
-        return willfail ? (void*)0:(void*)(-1);
-      }
-
-      std::string next()
-      {
-        std::string prev(current);
-        dirent* entry = readdir(handle);
-        if (entry)
-          current = entry->d_name;
-        else
-          willfail = true;
-        return prev;
-      }
-
-    private:
-      DIR* handle;
-      bool willfail;
-      std::string current;
-  };
-}
-
-#elif defined(OSLINK_OSDIR_WINDOWS)
-
-#ifdef DATADIR
-#undef DATADIR
-#endif
-
-#include <windows.h>
-#include <winbase.h>
-
-namespace OS
-{
-  class Directory
-  {
-    public:
-      Directory(const std::string& directoryName = "")
-          : handle(INVALID_HANDLE_VALUE), willfail(true)
-      {
-        this->open(directoryName);
-      }
-
-      ~Directory()
-      {
-	this->close();
-      }
-
-      bool open(const std::string& directoryName)
-      {
-        if (handle != INVALID_HANDLE_VALUE)
-          this->close();
-
-        // First check the attributes trying to access a non-Directory with
-        // FindFirstFile takes ages
-        DWORD attrs = GetFileAttributes(directoryName.c_str());
-        if ( (attrs == 0xFFFFFFFF) || ((attrs && FILE_ATTRIBUTE_DIRECTORY) == 0) )
-        {
-          willfail = true;
-          return false;
-        }
-        std::string Full(directoryName);
-        // Circumvent a problem in FindFirstFile with c:\\* as parameter
-        if ( (Full.length() > 0) && (Full[Full.length()-1] != '\\') )
-          Full += "\\";
-        WIN32_FIND_DATA entry;
-        handle = FindFirstFile( (Full+"*").c_str(), &entry);
-        if (handle == INVALID_HANDLE_VALUE)
-	  {
-	    willfail = true;
-	    return false;
-	  }
-        else
-	  {
-	    willfail = false;
-	    current = entry.cFileName;
-	    return true;
-	  }
-      }
-
-      void close()
-      {
-        if (handle != INVALID_HANDLE_VALUE)
-          FindClose(handle);
-        this->willfail = true;
-      }
-
-      operator void*() const
-      {
-        return willfail ? (void*)0:(void*)(-1);
-      }
-
-      std::string next()
-      {
-        std::string prev = current;
-        WIN32_FIND_DATA entry;
-        int ok = FindNextFile(handle, &entry);
-        if (!ok)
-          willfail = true;
-        else
-          current = entry.cFileName;
-        return current;
-      }
-
-
-    private:
-      HANDLE    handle;
-      bool      willfail;
-      std::string current;
-  };
-}
-
-
-#endif
-
-#endif
-
-/**
- *
- * The "library", above, refers to the collection of software functions
- * and/or data contained in this file, prepared so as to be conveniently
- * compiled and linked with application programs (which use some of those
- * functions and data) to form executables.
- *
- *                             NO WARRANTY
- *
- * 1. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
- * WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
- * EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
- * OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
- * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
- * LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
- * THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
- *
- * 2. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
- * WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
- * AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
- * FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
- * CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
- * LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
- * RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
- * FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
- * SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGES.
- *
- * END OF TERMS AND CONDITIONS
- *
- */
-
Index: trunk/src/lib/util/preferences.cc
===================================================================
--- trunk/src/lib/util/preferences.cc	(revision 7477)
+++ trunk/src/lib/util/preferences.cc	(revision 7661)
@@ -17,6 +17,5 @@
 
 #include "preferences.h"
-
-using namespace std;
+#include "lib/parser/ini_parser/ini_parser.h"
 
 
@@ -137,5 +136,5 @@
  * @return value of the item if found. defaultValue else
  */
-const std::string Preferences::getString(const std::string& section, const std::string& name, const std::string& defaultValue)
+std::string Preferences::getString(const std::string& section, const std::string& name, const std::string& defaultValue)
 {
   return getMultiType(section, name, MultiType(defaultValue)).getString();
@@ -260,7 +259,4 @@
   IniParser iniParser(this->fileName);
 
-  if ( !iniParser.isOpen() )
-    return false;
-
   std::list<prefSection>::iterator it = data.begin();
   bool didChanges = false;
@@ -278,6 +274,6 @@
     }
   }
-
-  if ( didChanges )
+  /// HACK DO WE HAVE TO CHECK THIS??
+  //if ( didChanges )
   {
     iniParser.writeFile( this->fileName );
@@ -314,5 +310,5 @@
 {
   std::list<std::string> lst;
-  
+
   std::list<prefSection>::const_iterator it = data.begin();
 
Index: trunk/src/lib/util/preferences.h
===================================================================
--- trunk/src/lib/util/preferences.h	(revision 7477)
+++ trunk/src/lib/util/preferences.h	(revision 7661)
@@ -9,5 +9,4 @@
 #include "base_object.h"
 #include "multi_type.h"
-#include "lib/parser/ini_parser/ini_parser.h"
 
 // FORWARD DECLARATION
@@ -44,5 +43,5 @@
    void setMultiType(const std::string& section, const std::string& name, const MultiType& value, bool dontSetModified = false);
 
-   const std::string getString(const std::string& section, const std::string& name, const std::string& defaultValue);
+   std::string getString(const std::string& section, const std::string& name, const std::string& defaultValue);
    int getInt(const std::string& section, const std::string& name, int defaultValue);
    float getFloat(const std::string& section, const std::string& name, float defaultValue);
@@ -54,5 +53,5 @@
 
    void debug();
-   
+
    std::list<std::string> listKeys( const std::string section );
 
