Index: orxonox/branches/heightMap/src/util/resource_manager.cc
===================================================================
--- orxonox/branches/heightMap/src/util/resource_manager.cc	(revision 3918)
+++ orxonox/branches/heightMap/src/util/resource_manager.cc	(revision 4122)
@@ -92,9 +92,31 @@
       this->dataDir = new char[strlen(dataDir)+1];
       strcpy(this->dataDir, dataDir);
+      return true;
     }
   else
     {
       PRINTF(1)("%s is not a Directory, and can not be the Data Directory, leaving as %s \n", dataDir, this->dataDir);
-    }
+      return false;
+    }
+}
+
+/**
+   \brief checks for the DataDirectory, by looking if 
+   \param fileInside is inisde??
+*/
+bool ResourceManager::checkDataDir(const char* fileInside)
+{
+  bool retVal;
+  if (!isDir(this->dataDir))
+    {
+      PRINTF(1)("%s is not a directory\n", this->dataDir);
+      return false;
+    }
+  
+  char* testFile = new char[strlen(this->dataDir)+strlen(fileInside)+1];
+  sprintf(testFile, "%s%s", this->dataDir, fileInside);
+  retVal = isFile(testFile);
+  delete testFile;
+  return retVal;
 }
 
@@ -180,5 +202,5 @@
   // searching if the resource was loaded before.
   Resource* tmpResource = this->locateResourceByInfo(fileName, type, param1, param2,param3);
-  if (tmpResource) // if the resource was not loaded before.
+  if (tmpResource) // if the resource was loaded before.
     {
       PRINTF(4)("not loading cached resource %s\n", tmpResource->name);
@@ -199,7 +221,6 @@
 
       // creating the full name. (directoryName + FileName)
-      char* fullName = new char[strlen(dataDir)+strlen(fileName)+1];
-      sprintf(fullName, "%s%s", this->dataDir, fileName);
-      
+      char* fullName = new char[strlen(this->getDataDir())+strlen(fileName)+1];
+      sprintf(fullName, "%s%s", this->getDataDir(), fileName);
       // Checking for the type of resource \see ResourceType
       switch(type)
@@ -211,5 +232,5 @@
 	    tmpResource->modelSize = 1.0;
 
-	  if(isFile(fullName))
+	  if(ResourceManager::isFile(fullName))
 	    tmpResource->pointer = new OBJModel(fullName, tmpResource->modelSize);
 	  else
@@ -508,19 +529,23 @@
     }
 
-  stat(tmpDirName, &status);
-  if (status.st_mode & (S_IFDIR
+  if(!stat(tmpDirName, &status))
+    {
+      if (status.st_mode & (S_IFDIR
 #ifndef __WIN32__
-			| S_IFLNK
+			    | S_IFLNK
 #endif
-			))
-    {
-      delete tmpDirName;
-      return true;
+			    ))
+	{
+	  delete tmpDirName;
+	  return true;
+	}
+      else
+	{
+	  delete tmpDirName;
+	  return false;
+	}
     }
   else
-    {
-      delete tmpDirName;
-      return false;
-    }
+    return false;
 }
 
@@ -532,15 +557,76 @@
 bool ResourceManager::isFile(const char* fileName)
 {
+  char* tmpFileName = ResourceManager::homeDirCheck(fileName);
+  // actually checks the File
   struct stat status;
-  stat(fileName, &status);
-  if (status.st_mode & (S_IFREG 
+  if (!stat(tmpFileName, &status))
+    {
+      if (status.st_mode & (S_IFREG 
 #ifndef __WIN32__
-			| S_IFLNK
+			    | S_IFLNK
 #endif
-			))
-    return true;
+			    ))
+	{
+	  delete tmpFileName;
+	  return true;
+	}
+      else
+	{
+	  delete tmpFileName;
+	  return false;
+	}
+    }
+  else 
+    {
+      delete tmpFileName;
+      return false;
+    }
+}
+
+bool ResourceManager::touchFile(const char* fileName)
+{
+  char* tmpName = ResourceManager::homeDirCheck(fileName);
+
+  FILE* stream;
+  if( (stream = fopen (tmpName, "w")) == NULL)
+    {
+      PRINTF(1)("could not open %s fro writing\n", fileName);
+      return false;
+    }
+  fclose(stream);
+    
+  delete tmpName; 
+}
+
+bool ResourceManager::deleteFile(const char* fileName)
+{
+  char* tmpName = ResourceManager::homeDirCheck(fileName);
+  unlink(tmpName);
+  delete tmpName;
+}
+
+char* ResourceManager::homeDirCheck(const char* name)
+{
+  char* retName;
+  if (!strncmp(name, "~/", 2))
+    {
+      char tmpFileName[500];
+#ifdef __WIN32__
+      strcpy(tmpFileName, getenv("USERPROFILE"));
+#else
+      strcpy(tmpFileName, getenv("HOME"));
+#endif
+      retName = new char[strlen(tmpFileName)+strlen(name)];
+      sprintf(retName, "%s%s", tmpFileName, name+1);
+    }
   else
-    return false;
-}
+    {
+      retName = new char[strlen(name)+1];
+      strcpy(retName, name);
+    }
+  return retName;
+}
+
+
 
 /**
