Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7624 in orxonox.OLD for branches


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

orxonox/qt_gui: directory is a File now

Location:
branches/qt_gui
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/qt_gui/config.h.in

    r6838 r7624  
    11/* config.h.in.  Generated from configure.ac by autoheader.  */
    2 
    3 /* Define to the read-only architecture-independent data directory. */
    4 #undef DATADIR
    52
    63/* in which debug mode we are */
     
    9592#undef MODULAR_DEBUG
    9693
     94/* Define to the read-only architecture-independent data directory of ORXONOX.
     95   */
     96#undef ORX_DATADIR
     97
    9798/* Name of package */
    9899#undef PACKAGE
  • branches/qt_gui/configure.ac

    r7608 r7624  
    3838AM_INIT_AUTOMAKE
    3939
    40 AC_CONFIG_SRCDIR([./src])
     40AC_CONFIG_SRCDIR([src/orxonox.cc])
    4141AC_CONFIG_HEADER([config.h])
    4242
     
    6464        echo "given: $DATA_DIR"
    6565fi
    66 AC_DEFINE_UNQUOTED([DATADIR], ["$DATA_DIR"],
     66AC_DEFINE_UNQUOTED([ORX_DATADIR], ["$DATA_DIR"],
    6767                   [Define to the read-only architecture-independent
    68                     data directory.])
     68                    data directory of ORXONOX.])
    6969
    7070#-----------------#
  • branches/qt_gui/src/defs/globals.h

    r7608 r7624  
    2525#define   DEFAULT_CONFIG_FILE              "~/.orxonox/orxonox.conf"
    2626#define   DEFAULT_LOCK_FILE                "~/.orxonox/orxonox.lock"
    27 #define   DEFAULT_DATA_DIR                 DATADIR "/orxonox/"
     27#define   DEFAULT_DATA_DIR                 ORX_DATADIR "/orxonox/"
    2828#define   DEFAULT_DATA_DIR_CHECKFILE       "data.oxd"
    2929
  • branches/qt_gui/src/lib/parser/ini_parser/ini_parser.h

    r7256 r7624  
    1010
    1111#define PARSELINELENGHT     512       //!< how many chars to read at once
    12 #ifndef NULL
    13  #define NULL 0x0                     //!< NULL
    14 #endif
    1512
     13#include "src/lib/util/file.h"
    1614#include <list>
    17 #include <string>
    1815
    1916//! ini-file parser
  • 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}
  • branches/qt_gui/src/lib/util/directory.h

    r7610 r7624  
     1/*!
     2 * @file directory.h
     3 * @brief Definition of the Directory Handler class
     4 */
     5
     6
    17/**
    28 * Copyright (C) 2002 Bart Vanhauwaert
     
    2026#define __DIRECTORY_H_
    2127
    22 #if defined(unix) || defined(__unix) || defined(__unix__)
    23 #define OSLINK_OSDIR_POSIX
    24 #elif defined(_WIN32)
    25 #define OSLINK_OSDIR_WINDOWS
     28#include "file.h"
     29
     30#if not defined (__WIN32__)
     31 #include <sys/types.h>
     32 #include <dirent.h>
    2633#else
    27 #define OSLINK_OSDIR_NOTSUPPORTED
     34 #include <windows.h>
     35 #include <winbase.h>
    2836#endif
    2937
    30 #include <string>
    31 
    32 #if defined(OSLINK_OSDIR_NOTSUPPORTED)
    33 #warning DIRECTORY NOT SUPPORTET
    34 
    35 #elif defined(OSLINK_OSDIR_POSIX)
    36 #include <sys/types.h>
    37 #include <dirent.h>
    38 
    39 #elif defined(OSLINK_OSDIR_WINDOWS)
    40 
    41 /// HACK
    42 #ifdef DATADIR
    43 #undef DATADIR
    44 #endif
    45 
    46 #include <windows.h>
    47 #include <winbase.h>
    48 
    49 #endif
    50 
    51 class Directory
     38class Directory : public File
    5239{
    5340public:
     
    5542  ~Directory();
    5643
    57   bool open(const std::string& directoryName);
    58   void close();
     44  virtual bool open(const std::string& directoryName);
     45  virtual bool close();
    5946  operator void*() const { return willfail ? (void*)0:(void*)(-1); }
    6047
    6148  std::string next();
    6249
     50  bool create();
     51
    6352private:
    64 #if defined(OSLINK_OSDIR_POSIX)
     53#if not defined(__WIN32__)
    6554  DIR* handle;
    66 #elif defined(OSLINK_OSDIR_WINDOWS)
    67     HANDLE    handle;
     55#else
     56  HANDLE    handle;
    6857#endif
    6958  bool willfail;
  • branches/qt_gui/src/lib/util/file.cc

    r7623 r7624  
    263263 *
    264264 * if the File was opened, it will be closed throuh this function.
     265 * The File will also be closed, if the File was not renamed.
    265266 */
    266267bool File::rename(const File& destination)
    267268{
     269  this->close();
     270
    268271  if (!std::rename(this->_name.c_str(), destination.name().c_str()))
    269272  {
    270     this->close();
    271273    this->_name = destination.name();
    272274    this->statFile();
    273 
    274275    return true;
    275276  }
     
    292293  }
    293294  fclose(stream);
     295
     296  this->statFile();
    294297  return true;
    295298}
Note: See TracChangeset for help on using the changeset viewer.