Index: trunk/src/lib/util/directory.cc
===================================================================
--- trunk/src/lib/util/directory.cc	(revision 8271)
+++ trunk/src/lib/util/directory.cc	(revision 8276)
@@ -38,110 +38,114 @@
 
 #if not defined (__WIN32__)
- #include <sys/stat.h>
- #include <sys/types.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <dirent.h>
+#else
+#include <windows.h>
+#include <winbase.h>
 #endif
+
+#include <iostream>
+
+/**
+ * @brief Constructs a Directory handler.
+ * @param directoryName the name of the Directory to access.
+ */
 Directory::Directory(const std::string& directoryName)
-  : File(directoryName), willfail(false)
+    : File(directoryName)
 {
-  this->handle = 0;
-  this->willfail = true;
+  this->_opened = false;
 }
 
+/**
+ * @brief destructs the Directory.
+ */
 Directory::~Directory()
 {
+  this->close();
 }
 
+
+/**
+ * @brief openes the Directory
+ * @returns true on success, false on error. (does not exist, no rights -> test with functions of File)
+ *
+ * Fills the List of Files, and sets the Directory to open state
+ */
 bool Directory::open()
 {
+  if (this->_opened)
+    this->close();
+
+  // Openes the Directory for reading:
 #if not defined(__WIN32__)
-  if (this->handle != NULL)
-    this->close();
-  this->handle = opendir(this->name().c_str());
+  DIR* handle;
+  handle = opendir(this->name().c_str());
   if (!handle)
-    willfail = true;
+  {
+    std::cerr << "could not open directory " << this->name() << " for reading" << std::endl;
+    return false;
+  }
+#else
+  HANDLE handle;
+
+  // 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) )
+  {
+    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)
+  {
+    std::cerr << "could not open directory " << this->name() << " for reading" << std::endl;
+    return false;
+  }
   else
   {
-    willfail = false;
-    dirent* entry = readdir(handle);
-    if (entry)
-      current = entry->d_name;
-    else
-      willfail = true;
+    this->_fileNames.push_back(entry.cFileName);
   }
-#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
 
+  // BUILDING the list of contained Files. (only the names)
+#if not defined(__WIN32__)
+  dirent* entry;
+  while ((entry = readdir(handle)) != NULL)
+    this->_fileNames.push_back(entry->d_name);
+  closedir(handle);
+#else
+  WIN32_FIND_DATA entry;
+  while ((int ok = FindNextFile(handle, &entry)) != 0)
+    this->_fileNames.push_back(entry.cFileName);
+  FindClose(handle);
+#endif
+  this->_opened = true;
+  return true;
 }
 
+/**
+ * @brief closes the directory
+ * @returns true.
+ *
+ * Clears the List of Files in the Directory.
+ */
 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 = "";
+  this->_opened = false;
+  this->_fileNames.clear();
   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
-}
-
-
+/**
+ * @brief creates the directory
+ * @returns true on success, false on error
+ */
 bool Directory::create()
 {
Index: trunk/src/lib/util/directory.h
===================================================================
--- trunk/src/lib/util/directory.h	(revision 8271)
+++ trunk/src/lib/util/directory.h	(revision 8276)
@@ -27,12 +27,5 @@
 
 #include "file.h"
-
-#if not defined (__WIN32__)
- #include <sys/types.h>
- #include <dirent.h>
-#else
- #include <windows.h>
- #include <winbase.h>
-#endif
+#include <vector>
 
 class Directory : public File
@@ -44,18 +37,23 @@
   virtual bool open();
   virtual bool close();
-  operator void*() const { return willfail ? (void*)0:(void*)(-1); }
-
-  std::string next();
 
   bool create();
 
+  /** @returns if the Directory was opened */
+  bool isOpen() const { return this->_opened; }
+  /** @returns the FileCount (count of files contained in this directory) */
+  unsigned int fileCount() const { return _fileNames.size(); };
+  /** @returns the FileNames contained inside of the Directory */
+  const std::vector<std::string>& fileNames() const { return this->_fileNames; };
+  /** @returns the i'th FileName @param fileNumber the fileNumber (must not bigger than fileCount()) */
+  const std::string& operator[](unsigned int fileNumber) const { return this->_fileNames[fileNumber]; };
+  /** @returns a formated string containing the FileName, prepended with the directory-Name */
+  std::string fileNameInDir(unsigned int fileNumber) const { return this->name() + "/" + _fileNames[fileNumber]; };
+  /** @returns a File pointing to the File @param fileNumber the fileNumber (must not bigger than fileCount()) */
+  File getFile(unsigned int fileNumber) const { return File(fileNameInDir(fileNumber)); };
+
 private:
-#if not defined(__WIN32__)
-  DIR* handle;
-#else
-  HANDLE    handle;
-#endif
-  bool willfail;
-  std::string current;
+  bool                        _opened;          //!< If the directory was opened.
+  std::vector<std::string>    _fileNames;       //!< The List of Files contained in the directory. (will be filled when open was called.)
 };
 
Index: trunk/src/lib/util/file.cc
===================================================================
--- trunk/src/lib/util/file.cc	(revision 8271)
+++ trunk/src/lib/util/file.cc	(revision 8276)
@@ -160,4 +160,5 @@
 {
 #warning implement
+  return false;
 }
 
@@ -165,4 +166,5 @@
 {
 #warning implement
+  return false;
 }
 
@@ -249,4 +251,5 @@
     oFile.put(ch);
   }
+  return true;
 }
 
@@ -298,8 +301,13 @@
 bool File::remove()
 {
+  if (!this->exists())
+    return false;
+
   this->close();
   unlink(this->_name.c_str());
   delete this->_status;
   this->_status = NULL;
+
+  return true;
 }
 
