[7624] | 1 | /*! |
---|
| 2 | * @file directory.h |
---|
| 3 | * @brief Definition of the Directory Handler class |
---|
| 4 | */ |
---|
| 5 | |
---|
| 6 | |
---|
[7422] | 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 | |
---|
[7610] | 25 | #ifndef __DIRECTORY_H_ |
---|
| 26 | #define __DIRECTORY_H_ |
---|
[7422] | 27 | |
---|
[7624] | 28 | #include "file.h" |
---|
[8276] | 29 | #include <vector> |
---|
[7624] | 30 | |
---|
| 31 | class Directory : public File |
---|
[7422] | 32 | { |
---|
[7610] | 33 | public: |
---|
| 34 | Directory(const std::string& directoryName = ""); |
---|
| 35 | ~Directory(); |
---|
[7425] | 36 | |
---|
[7625] | 37 | virtual bool open(); |
---|
[7624] | 38 | virtual bool close(); |
---|
[7425] | 39 | |
---|
[7624] | 40 | bool create(); |
---|
| 41 | |
---|
[8276] | 42 | /** @returns if the Directory was opened */ |
---|
| 43 | bool isOpen() const { return this->_opened; } |
---|
| 44 | /** @returns the FileCount (count of files contained in this directory) */ |
---|
| 45 | unsigned int fileCount() const { return _fileNames.size(); }; |
---|
| 46 | /** @returns the FileNames contained inside of the Directory */ |
---|
| 47 | const std::vector<std::string>& fileNames() const { return this->_fileNames; }; |
---|
| 48 | /** @returns the i'th FileName @param fileNumber the fileNumber (must not bigger than fileCount()) */ |
---|
| 49 | const std::string& operator[](unsigned int fileNumber) const { return this->_fileNames[fileNumber]; }; |
---|
| 50 | /** @returns a formated string containing the FileName, prepended with the directory-Name */ |
---|
| 51 | std::string fileNameInDir(unsigned int fileNumber) const { return this->name() + "/" + _fileNames[fileNumber]; }; |
---|
| 52 | /** @returns a File pointing to the File @param fileNumber the fileNumber (must not bigger than fileCount()) */ |
---|
| 53 | File getFile(unsigned int fileNumber) const { return File(fileNameInDir(fileNumber)); }; |
---|
| 54 | |
---|
[7610] | 55 | private: |
---|
[8276] | 56 | bool _opened; //!< If the directory was opened. |
---|
| 57 | std::vector<std::string> _fileNames; //!< The List of Files contained in the directory. (will be filled when open was called.) |
---|
[7610] | 58 | }; |
---|
[7425] | 59 | |
---|
[7610] | 60 | #endif /* __DIRECTORY_H_ */ |
---|
[7425] | 61 | |
---|
[7422] | 62 | /** |
---|
| 63 | * |
---|
| 64 | * The "library", above, refers to the collection of software functions |
---|
| 65 | * and/or data contained in this file, prepared so as to be conveniently |
---|
| 66 | * compiled and linked with application programs (which use some of those |
---|
| 67 | * functions and data) to form executables. |
---|
| 68 | * |
---|
| 69 | * NO WARRANTY |
---|
| 70 | * |
---|
| 71 | * 1. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO |
---|
| 72 | * WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. |
---|
| 73 | * EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR |
---|
| 74 | * OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY |
---|
| 75 | * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE |
---|
| 76 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
---|
| 77 | * PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE |
---|
| 78 | * LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME |
---|
| 79 | * THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. |
---|
| 80 | * |
---|
| 81 | * 2. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN |
---|
| 82 | * WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY |
---|
| 83 | * AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU |
---|
| 84 | * FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR |
---|
| 85 | * CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE |
---|
| 86 | * LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING |
---|
| 87 | * RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A |
---|
| 88 | * FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF |
---|
| 89 | * SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH |
---|
| 90 | * DAMAGES. |
---|
| 91 | * |
---|
| 92 | * END OF TERMS AND CONDITIONS |
---|
| 93 | * |
---|
| 94 | */ |
---|
| 95 | |
---|