| [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" | 
|---|
|  | 29 |  | 
|---|
|  | 30 | #if not defined (__WIN32__) | 
|---|
|  | 31 | #include <sys/types.h> | 
|---|
|  | 32 | #include <dirent.h> | 
|---|
| [7422] | 33 | #else | 
|---|
| [7624] | 34 | #include <windows.h> | 
|---|
|  | 35 | #include <winbase.h> | 
|---|
| [7422] | 36 | #endif | 
|---|
|  | 37 |  | 
|---|
| [7624] | 38 | class Directory : public File | 
|---|
| [7422] | 39 | { | 
|---|
| [7610] | 40 | public: | 
|---|
|  | 41 | Directory(const std::string& directoryName = ""); | 
|---|
|  | 42 | ~Directory(); | 
|---|
| [7425] | 43 |  | 
|---|
| [7625] | 44 | virtual bool open(); | 
|---|
| [7624] | 45 | virtual bool close(); | 
|---|
| [7610] | 46 | operator void*() const { return willfail ? (void*)0:(void*)(-1); } | 
|---|
| [7425] | 47 |  | 
|---|
| [7610] | 48 | std::string next(); | 
|---|
| [7425] | 49 |  | 
|---|
| [7624] | 50 | bool create(); | 
|---|
|  | 51 |  | 
|---|
| [7610] | 52 | private: | 
|---|
| [7624] | 53 | #if not defined(__WIN32__) | 
|---|
| [7610] | 54 | DIR* handle; | 
|---|
| [7624] | 55 | #else | 
|---|
|  | 56 | HANDLE    handle; | 
|---|
| [7610] | 57 | #endif | 
|---|
|  | 58 | bool willfail; | 
|---|
|  | 59 | std::string current; | 
|---|
|  | 60 | }; | 
|---|
| [7425] | 61 |  | 
|---|
| [7610] | 62 | #endif /* __DIRECTORY_H_ */ | 
|---|
| [7425] | 63 |  | 
|---|
| [7422] | 64 | /** | 
|---|
|  | 65 | * | 
|---|
|  | 66 | * The "library", above, refers to the collection of software functions | 
|---|
|  | 67 | * and/or data contained in this file, prepared so as to be conveniently | 
|---|
|  | 68 | * compiled and linked with application programs (which use some of those | 
|---|
|  | 69 | * functions and data) to form executables. | 
|---|
|  | 70 | * | 
|---|
|  | 71 | *                             NO WARRANTY | 
|---|
|  | 72 | * | 
|---|
|  | 73 | * 1. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO | 
|---|
|  | 74 | * WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. | 
|---|
|  | 75 | * EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR | 
|---|
|  | 76 | * OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY | 
|---|
|  | 77 | * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE | 
|---|
|  | 78 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 
|---|
|  | 79 | * PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE | 
|---|
|  | 80 | * LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME | 
|---|
|  | 81 | * THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. | 
|---|
|  | 82 | * | 
|---|
|  | 83 | * 2. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN | 
|---|
|  | 84 | * WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY | 
|---|
|  | 85 | * AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU | 
|---|
|  | 86 | * FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR | 
|---|
|  | 87 | * CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE | 
|---|
|  | 88 | * LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING | 
|---|
|  | 89 | * RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A | 
|---|
|  | 90 | * FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF | 
|---|
|  | 91 | * SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH | 
|---|
|  | 92 | * DAMAGES. | 
|---|
|  | 93 | * | 
|---|
|  | 94 | * END OF TERMS AND CONDITIONS | 
|---|
|  | 95 | * | 
|---|
|  | 96 | */ | 
|---|
|  | 97 |  | 
|---|