Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8276 in orxonox.OLD for trunk/src/lib/util/directory.h


Ignore:
Timestamp:
Jun 8, 2006, 5:21:29 PM (19 years ago)
Author:
bensch
Message:

merged new GUI

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/util/directory.h

    r7661 r8276  
    2727
    2828#include "file.h"
    29 
    30 #if not defined (__WIN32__)
    31  #include <sys/types.h>
    32  #include <dirent.h>
    33 #else
    34  #include <windows.h>
    35  #include <winbase.h>
    36 #endif
     29#include <vector>
    3730
    3831class Directory : public File
     
    4437  virtual bool open();
    4538  virtual bool close();
    46   operator void*() const { return willfail ? (void*)0:(void*)(-1); }
    47 
    48   std::string next();
    4939
    5040  bool create();
    5141
     42  /** @returns if the Directory was opened */
     43  bool isOpen() const { return this->_opened; }
     44  /** @returns the FileCount (count of files contained in this directory) */
     45  unsigned int fileCount() const { return _fileNames.size(); };
     46  /** @returns the FileNames contained inside of the Directory */
     47  const std::vector<std::string>& fileNames() const { return this->_fileNames; };
     48  /** @returns the i'th FileName @param fileNumber the fileNumber (must not bigger than fileCount()) */
     49  const std::string& operator[](unsigned int fileNumber) const { return this->_fileNames[fileNumber]; };
     50  /** @returns a formated string containing the FileName, prepended with the directory-Name */
     51  std::string fileNameInDir(unsigned int fileNumber) const { return this->name() + "/" + _fileNames[fileNumber]; };
     52  /** @returns a File pointing to the File @param fileNumber the fileNumber (must not bigger than fileCount()) */
     53  File getFile(unsigned int fileNumber) const { return File(fileNameInDir(fileNumber)); };
     54
    5255private:
    53 #if not defined(__WIN32__)
    54   DIR* handle;
    55 #else
    56   HANDLE    handle;
    57 #endif
    58   bool willfail;
    59   std::string current;
     56  bool                        _opened;          //!< If the directory was opened.
     57  std::vector<std::string>    _fileNames;       //!< The List of Files contained in the directory. (will be filled when open was called.)
    6058};
    6159
Note: See TracChangeset for help on using the changeset viewer.