Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7624 in orxonox.OLD for branches/qt_gui/src/lib/util/directory.cc


Ignore:
Timestamp:
May 16, 2006, 9:04:24 AM (19 years ago)
Author:
bensch
Message:

orxonox/qt_gui: directory is a File now

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/qt_gui/src/lib/util/directory.cc

    r7610 r7624  
    3636
    3737#include "directory.h"
     38
     39#if not defined (__WIN32__)
     40 #include <sys/stat.h>
     41 #include <sys/types.h>
     42#endif
    3843Directory::Directory(const std::string& directoryName)
    3944    : willfail(false)
     
    4146  this->handle = 0;
    4247  this->willfail = true;
    43   this->open(directoryName);
    4448}
    4549
    4650Directory::~Directory()
    4751{
    48   this->close();
    4952}
    5053
    5154bool Directory::open(const std::string& directoryName)
    5255{
    53 #if defined(OSLINK_OSDIR_POSIX)
     56#if not defined(__WIN32__)
    5457  if (this->handle != NULL)
    5558    this->close();
     
    6669      willfail = true;
    6770  }
    68 #elif defined(OSLINK_OSDIR_WINDOWS)
     71#else
    6972    if (handle != INVALID_HANDLE_VALUE)
    7073      this->close();
     
    99102}
    100103
    101 void Directory::close()
     104bool Directory::close()
    102105{
    103 #if defined(OSLINK_OSDIR_POSIX)
     106#if not defined(__WIN32__)
    104107  if (this->handle != NULL)
    105108    closedir(handle);
    106109  this->handle = NULL;
    107 #elif defined(OSLINK_OSDIR_WINDOWS)
     110#else
    108111  if (handle != INVALID_HANDLE_VALUE)
    109112    FindClose(handle);
     
    112115  this->willfail = true;
    113116  this->current = "";
     117  return true;
    114118}
    115119
     
    118122std::string Directory::next()
    119123{
    120 #if defined(OSLINK_OSDIR_POSIX)
     124#if not defined(__WIN32__)
    121125  std::string prev(current);
    122126  dirent* entry = readdir(handle);
     
    127131  return prev;
    128132
    129 #elif defined(OSLINK_OSDIR_WINDOWS)
     133#else
    130134  std::string prev = current;
    131135  WIN32_FIND_DATA entry;
     
    138142#endif
    139143}
     144
     145
     146bool Directory::create()
     147{
     148#if not defined (__WIN32__)
     149  return (!mkdir(this->name().c_str(), 0777));
     150#else
     151  return (!CreateDirectory(this->name().c_str(), NULL));
     152#endif
     153}
Note: See TracChangeset for help on using the changeset viewer.