Index: branches/qt_gui/src/lib/util/directory.cc
===================================================================
--- branches/qt_gui/src/lib/util/directory.cc	(revision 7610)
+++ branches/qt_gui/src/lib/util/directory.cc	(revision 7610)
@@ -0,0 +1,139 @@
+/*
+   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"
+Directory::Directory(const std::string& directoryName)
+    : willfail(false)
+{
+  this->handle = 0;
+  this->willfail = true;
+  this->open(directoryName);
+}
+
+Directory::~Directory()
+{
+  this->close();
+}
+
+bool Directory::open(const std::string& directoryName)
+{
+#if defined(OSLINK_OSDIR_POSIX)
+  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;
+  }
+#elif defined(OSLINK_OSDIR_WINDOWS)
+    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;
+    }
+#endif
+
+}
+
+void Directory::close()
+{
+#if defined(OSLINK_OSDIR_POSIX)
+  if (this->handle != NULL)
+    closedir(handle);
+  this->handle = NULL;
+#elif defined(OSLINK_OSDIR_WINDOWS)
+  if (handle != INVALID_HANDLE_VALUE)
+    FindClose(handle);
+    handle = 0;
+#endif
+  this->willfail = true;
+  this->current = "";
+}
+
+
+
+std::string Directory::next()
+{
+#if defined(OSLINK_OSDIR_POSIX)
+  std::string prev(current);
+  dirent* entry = readdir(handle);
+  if (entry)
+    current = entry->d_name;
+  else
+    willfail = true;
+  return prev;
+
+#elif defined(OSLINK_OSDIR_WINDOWS)
+  std::string prev = current;
+  WIN32_FIND_DATA entry;
+  int ok = FindNextFile(handle, &entry);
+  if (!ok)
+    willfail = true;
+  else
+    current = entry.cFileName;
+  return current;
+#endif
+}
Index: branches/qt_gui/src/lib/util/directory.h
===================================================================
--- branches/qt_gui/src/lib/util/directory.h	(revision 7609)
+++ branches/qt_gui/src/lib/util/directory.h	(revision 7610)
@@ -17,6 +17,6 @@
  */
 
-#ifndef OSLINK_OSDIR_HEADER_H_
-#define OSLINK_OSDIR_HEADER_H_
+#ifndef __DIRECTORY_H_
+#define __DIRECTORY_H_
 
 #if defined(unix) || defined(__unix) || defined(__unix__)
@@ -31,94 +31,13 @@
 
 #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 ""; }
-  };
-}
+#warning DIRECTORY NOT SUPPORTET
 
 #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)
 
+/// HACK
 #ifdef DATADIR
 #undef DATADIR
@@ -128,88 +47,31 @@
 #include <winbase.h>
 
-namespace OS
+#endif
+
+class Directory
 {
-  class Directory
-  {
-    public:
-      Directory(const std::string& directoryName = "")
-          : handle(INVALID_HANDLE_VALUE), willfail(true)
-      {
-        this->open(directoryName);
-      }
+public:
+  Directory(const std::string& directoryName = "");
+  ~Directory();
 
-      ~Directory()
-      {
-	this->close();
-      }
+  bool open(const std::string& directoryName);
+  void close();
+  operator void*() const { return willfail ? (void*)0:(void*)(-1); }
 
-      bool open(const std::string& directoryName)
-      {
-        if (handle != INVALID_HANDLE_VALUE)
-          this->close();
+  std::string next();
 
-        // 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:
+#if defined(OSLINK_OSDIR_POSIX)
+  DIR* handle;
+#elif defined(OSLINK_OSDIR_WINDOWS)
+    HANDLE    handle;
+#endif
+  bool willfail;
+  std::string current;
+};
 
 
-    private:
-      HANDLE    handle;
-      bool      willfail;
-      std::string current;
-  };
-}
 
-
-#endif
-
-#endif
+#endif /* __DIRECTORY_H_ */
 
 /**
