Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9869 in orxonox.OLD for trunk/src/lib/util/filesys


Ignore:
Timestamp:
Oct 3, 2006, 12:19:30 AM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the new_class_id branche back to the trunk.
merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/new_class_id trunk -r9683:HEAD
no conflicts… puh..

Location:
trunk/src/lib/util/filesys
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/util/filesys/directory.cc

    r8523 r9869  
    4141#include <sys/stat.h>
    4242#include <dirent.h>
     43const char Directory::delimiter = '/';
    4344#else
    4445#include <windows.h>
    4546#include <winbase.h>
     47const char Direcotry::delimiter = '\\';
    4648#endif
    4749
     
    6365 */
    6466Directory::Directory(const Directory& directory)
    65   : File(directory)
     67    : File(directory)
    6668{
    6769  this->_opened = directory._opened;
     
    166168#endif
    167169}
     170
     171
     172Directory Directory::operator+(const Directory& dir) const
     173{
     174  return Directory(*this) += dir;
     175}
     176
     177/**
     178 * @param dir the Directory to append to this one (say this one is "/var", then dir can be "log")
     179 * @returns The Directory appended by dir.
     180 *
     181 * @note the Directoy will again be closed even if it was opened previously!
     182 */
     183Directory& Directory::operator+=(const Directory& dir)
     184{
     185  this->setFileName(this->name() + Directory::delimiter + dir.name());
     186  return *this;
     187}
     188
     189/**
     190 * @brief Traverses the Directory tree one step up. (Parent Directory)
     191 * @returns a Reference to the Directory.
     192 */
     193Directory& Directory::operator--()
     194{
     195}
     196
     197
     198/**
     199 * @brief Traverses the Directory tree one step up. (Parent Directory)
     200 * @param int the PostFix iterator
     201 * @returns a Reference to the Directory.
     202 */
     203Directory& Directory::operator--(int)
     204{
     205}
     206
     207/**
     208 * @returns The Parent Directory.
     209 */
     210Directory Directory::parentDir() const
     211{
     212
     213}
     214
     215File operator+(const Directory& dir, const File& file)
     216{
     217  return File(dir.name() + Directory::delimiter + file.name());
     218}
  • trunk/src/lib/util/filesys/directory.h

    r8333 r9869  
    2929#include <vector>
    3030
     31//! A Directory is a Special file, that contains multiple Files.
     32/**
     33 * @example Correct usage
     34 * Directory dir("/var/log");
     35 * dir.open();
     36 * if (dir.fileNameInDir("emerge.log"))
     37 *  { // do stuff; }
     38 */
    3139class Directory : public File
    3240{
     
    4149  bool create();
    4250
     51  Directory operator+(const Directory& dir) const;
     52  Directory& operator+=(const Directory& dir);
     53  Directory& operator--();
     54  Directory& operator--(int);
     55  Directory parentDir() const;
     56
     57
    4358  /** @returns if the Directory was opened */
    4459  bool isOpen() const { return this->_opened; }
     
    5065  const std::string& operator[](unsigned int fileNumber) const { return this->_fileNames[fileNumber]; };
    5166  /** @returns a formated string containing the FileName, prepended with the directory-Name */
    52   std::string fileNameInDir(unsigned int fileNumber) const { return this->name() + "/" + _fileNames[fileNumber]; };
     67  std::string fileNameInDir(unsigned int fileNumber) const { return this->name() + Directory::delimiter + _fileNames[fileNumber]; };
    5368  /** @returns a File pointing to the File @param fileNumber the fileNumber (must not bigger than fileCount()) */
    5469  File getFile(unsigned int fileNumber) const { return File(fileNameInDir(fileNumber)); };
     70
     71public:
     72  static const char           delimiter;        //!< A Delimiter (*nix: '/', windows: '\\')
    5573
    5674private:
     
    5876  std::vector<std::string>    _fileNames;       //!< The List of Files contained in the directory. (will be filled when open was called.)
    5977};
     78
     79File operator+(const Directory& dir, const File& file);
    6080
    6181#endif /* __DIRECTORY_H_ */
  • trunk/src/lib/util/filesys/file.cc

    r8619 r9869  
    326326}
    327327
     328/**
     329 * @brief converts an Absolute Filename to a Relative one
     330 * @param absFileName the FileName to convert. The Relative path will be stored in absFileName.
     331 */
    328332void File::absToRel(std::string& absFileName)
    329333{
Note: See TracChangeset for help on using the changeset viewer.