Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/util/filesys/directory.h @ 9113

Last change on this file since 9113 was 8333, checked in by bensch, 19 years ago

trunk: some nicer updates

File size: 3.7 KB
Line 
1/*!
2 * @file directory.h
3 * @brief Definition of the Directory Handler class
4 */
5
6
7/**
8 * Copyright (C) 2002 Bart Vanhauwaert
9 *
10 * Permission to use, copy, modify, distribute and sell this software
11 * for any purpose is hereby granted without fee. This license
12 * includes (but is not limited to) standalone compilation or as part
13 * of a larger project.
14 *
15 * This software is provided "as is" without express or implied warranty.
16 *
17 * For a full statement on warranty and terms and conditions for
18 * copying, distribution and modification, please see the comment block
19 * at the end of this file.
20 *
21 * Version 1
22 *
23 */
24
25#ifndef __DIRECTORY_H_
26#define __DIRECTORY_H_
27
28#include "file.h"
29#include <vector>
30
31class Directory : public File
32{
33public:
34  Directory(const std::string& directoryName = "");
35  Directory(const Directory& directory);
36  virtual ~Directory();
37
38  virtual bool open();
39  virtual bool close();
40
41  bool create();
42
43  /** @returns if the Directory was opened */
44  bool isOpen() const { return this->_opened; }
45  /** @returns the FileCount (count of files contained in this directory) */
46  unsigned int fileCount() const { return _fileNames.size(); };
47  /** @returns the FileNames contained inside of the Directory */
48  const std::vector<std::string>& fileNames() const { return this->_fileNames; };
49  /** @returns the i'th FileName @param fileNumber the fileNumber (must not bigger than fileCount()) */
50  const std::string& operator[](unsigned int fileNumber) const { return this->_fileNames[fileNumber]; };
51  /** @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]; };
53  /** @returns a File pointing to the File @param fileNumber the fileNumber (must not bigger than fileCount()) */
54  File getFile(unsigned int fileNumber) const { return File(fileNameInDir(fileNumber)); };
55
56private:
57  bool                        _opened;          //!< If the directory was opened.
58  std::vector<std::string>    _fileNames;       //!< The List of Files contained in the directory. (will be filled when open was called.)
59};
60
61#endif /* __DIRECTORY_H_ */
62
63/**
64 *
65 * The "library", above, refers to the collection of software functions
66 * and/or data contained in this file, prepared so as to be conveniently
67 * compiled and linked with application programs (which use some of those
68 * functions and data) to form executables.
69 *
70 *                             NO WARRANTY
71 *
72 * 1. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
73 * WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
74 * EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
75 * OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
76 * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
77 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
78 * PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
79 * LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
80 * THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
81 *
82 * 2. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
83 * WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
84 * AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
85 * FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
86 * CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
87 * LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
88 * RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
89 * FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
90 * SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
91 * DAMAGES.
92 *
93 * END OF TERMS AND CONDITIONS
94 *
95 */
96
Note: See TracBrowser for help on using the repository browser.