42cf5bc1 |
1 | // Created on: 1992-05-18 |
2 | // Created by: Stephan GARNAUD |
3 | // Copyright (c) 1992-1999 Matra Datavision |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
5 | // |
6 | // This file is part of Open CASCADE Technology software library. |
7 | // |
8 | // This library is free software; you can redistribute it and/or modify it under |
9 | // the terms of the GNU Lesser General Public License version 2.1 as published |
10 | // by the Free Software Foundation, with special exception defined in the file |
11 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
12 | // distribution for complete text of the license and disclaimer of any warranty. |
13 | // |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
16 | |
17 | #ifndef _OSD_DirectoryIterator_HeaderFile |
18 | #define _OSD_DirectoryIterator_HeaderFile |
19 | |
20 | #include <Standard.hxx> |
21 | #include <Standard_DefineAlloc.hxx> |
22 | #include <Standard_Handle.hxx> |
23 | |
24 | #include <OSD_Directory.hxx> |
42cf5bc1 |
25 | #include <TCollection_AsciiString.hxx> |
42cf5bc1 |
26 | #include <OSD_Error.hxx> |
27 | #include <Standard_Boolean.hxx> |
42cf5bc1 |
28 | class OSD_Path; |
42cf5bc1 |
29 | |
30 | |
31 | //! Manages a breadth-only search for sub-directories in the specified |
32 | //! Path. |
33 | //! There is no specific order of results. |
34 | class OSD_DirectoryIterator |
35 | { |
36 | public: |
37 | |
38 | DEFINE_STANDARD_ALLOC |
39 | |
40 | |
41 | //! Instantiates Object as empty Iterator; |
42 | Standard_EXPORT OSD_DirectoryIterator(); |
43 | |
44 | //! Instantiates Object as Iterator. |
45 | //! Wild-card "*" can be used in Mask the same way it |
46 | //! is used by unix shell for file names |
47 | Standard_EXPORT OSD_DirectoryIterator(const OSD_Path& where, const TCollection_AsciiString& Mask); |
48 | |
49 | Standard_EXPORT void Destroy(); |
50 | ~OSD_DirectoryIterator() |
51 | { |
52 | Destroy(); |
53 | } |
54 | |
55 | //! Initializes the current File Directory |
56 | Standard_EXPORT void Initialize (const OSD_Path& where, const TCollection_AsciiString& Mask); |
57 | |
58 | //! Returns TRUE if other items are found while |
59 | //! using the 'Tree' method. |
60 | Standard_EXPORT Standard_Boolean More(); |
61 | |
62 | //! Sets the iterator to the next item. |
63 | //! Returns the item value corresponding to the current |
64 | //! position of the iterator. |
65 | Standard_EXPORT void Next(); |
66 | |
67 | //! Returns the next item found . |
68 | Standard_EXPORT OSD_Directory Values(); |
69 | |
70 | //! Returns TRUE if an error occurs |
71 | Standard_EXPORT Standard_Boolean Failed() const; |
72 | |
73 | //! Resets error counter to zero |
74 | Standard_EXPORT void Reset(); |
75 | |
76 | //! Raises OSD_Error |
77 | Standard_EXPORT void Perror(); |
78 | |
79 | //! Returns error number if 'Failed' is TRUE. |
80 | Standard_EXPORT Standard_Integer Error() const; |
81 | |
42cf5bc1 |
82 | private: |
42cf5bc1 |
83 | OSD_Directory TheIterator; |
dde68833 |
84 | Standard_Boolean myFlag; |
42cf5bc1 |
85 | TCollection_AsciiString myMask; |
86 | TCollection_AsciiString myPlace; |
42cf5bc1 |
87 | OSD_Error myError; |
d48df25d |
88 | |
89 | // platform-specific fields |
90 | #ifdef _WIN32 |
42cf5bc1 |
91 | Standard_Address myHandle; |
92 | Standard_Address myData; |
93 | Standard_Boolean myFirstCall; |
d48df25d |
94 | #else |
95 | Standard_Address myDescr; |
96 | Standard_Address myEntry; |
97 | Standard_Integer myInit; |
98 | #endif |
42cf5bc1 |
99 | }; |
100 | |
42cf5bc1 |
101 | #endif // _OSD_DirectoryIterator_HeaderFile |