Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7425 in orxonox.OLD for trunk/src/lib/util/osdir.h


Ignore:
Timestamp:
Apr 28, 2006, 6:05:02 PM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: should compile on Windows goin to check this today

File:
1 edited

Legend:

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

    r7422 r7425  
    129129  {
    130130    public:
    131       Directory(const std::string& aName)
    132           : handle(INVALID_HANDLE_VALUE), willfail(false)
    133       {
     131      Directory(const std::string& directoryName = "")
     132          : handle(INVALID_HANDLE_VALUE), willfail(true)
     133      {
     134        this->open(directoryName);
     135      }
     136
     137      ~Directory()
     138      {
     139          this->close
     140      }
     141
     142      bool open(const std::string& directoryName)
     143      {
     144        if (handle != INVALID_HANDLE_VALUE)
     145          this->close();
     146
    134147        // First check the attributes trying to access a non-Directory with
    135148        // FindFirstFile takes ages
    136         DWORD attrs = GetFileAttributes(aName.c_str());
     149        DWORD attrs = GetFileAttributes(directoryName.c_str());
    137150        if ( (attrs == 0xFFFFFFFF) || ((attrs && FILE_ATTRIBUTE_DIRECTORY) == 0) )
    138151        {
     
    140153          return;
    141154        }
    142         std::string Full(aName);
     155        std::string Full(directoryName);
    143156        // Circumvent a problem in FindFirstFile with c:\\* as parameter
    144157        if ( (Full.length() > 0) && (Full[Full.length()-1] != '\\') )
     
    151164          current = entry.cFileName;
    152165      }
    153       ~Directory()
     166
     167      void close()
    154168      {
    155169        if (handle != INVALID_HANDLE_VALUE)
    156170          FindClose(handle);
     171        this->willfail = true;
    157172      }
    158173
     
    161176        return willfail ? (void*)0:(void*)(-1);
    162177      }
     178
    163179      std::string next()
    164180      {
     
    172188        return current;
    173189      }
     190
     191
    174192    private:
    175193      HANDLE    handle;
Note: See TracChangeset for help on using the changeset viewer.