Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8224 in orxonox.OLD for branches/gui/src/lib/util/directory.h


Ignore:
Timestamp:
Jun 8, 2006, 10:10:51 AM (19 years ago)
Author:
bensch
Message:

gui: much better directory, now the Directory is completly read in when opening it.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/gui/src/lib/util/directory.h

    r7661 r8224  
    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 the FileNames contained inside of the Directory */
     43  const std::vector<std::string>& fileNames() const { return this->_fileNames; };
     44  const std::string& operator[](unsigned int fileNumber) const { return this->_fileNames[fileNumber]; };
     45  unsigned int fileCount() const { return _fileNames.size(); };
     46
     47  std::string fileNameInDir(unsigned int fileNumber) const { return this->name() + "/" + _fileNames[fileNumber]; };
     48
     49  File getFile(unsigned int fileNumber) const { return File(fileNameInDir(fileNumber)); };
     50
    5251private:
    53 #if not defined(__WIN32__)
    54   DIR* handle;
    55 #else
    56   HANDLE    handle;
    57 #endif
    58   bool willfail;
    59   std::string current;
     52  bool                        _opened;
     53  std::vector<std::string>    _fileNames;
    6054};
    6155
Note: See TracChangeset for help on using the changeset viewer.