42cf5bc1 |
1 | // Created on: 1992-03-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_FileIterator_HeaderFile |
18 | #define _OSD_FileIterator_HeaderFile |
19 | |
42cf5bc1 |
20 | #include <OSD_File.hxx> |
42cf5bc1 |
21 | #include <OSD_Error.hxx> |
d48df25d |
22 | #include <TCollection_AsciiString.hxx> |
23 | |
42cf5bc1 |
24 | class OSD_OSDError; |
25 | class OSD_Path; |
42cf5bc1 |
26 | class OSD_File; |
27 | |
d48df25d |
28 | //! Manages a breadth-only search for files in the specified Path. |
42cf5bc1 |
29 | //! There is no specific order of results. |
30 | class OSD_FileIterator |
31 | { |
32 | public: |
33 | |
34 | DEFINE_STANDARD_ALLOC |
35 | |
36 | |
37 | //! Instantiates Object as empty Iterator; |
38 | Standard_EXPORT OSD_FileIterator(); |
39 | |
40 | //! Instantiates Object as Iterator; |
41 | //! Wild-card "*" can be used in Mask the same way it |
42 | //! is used by unix shell for file names |
43 | Standard_EXPORT OSD_FileIterator(const OSD_Path& where, const TCollection_AsciiString& Mask); |
44 | |
45 | Standard_EXPORT void Destroy(); |
46 | ~OSD_FileIterator() |
47 | { |
48 | Destroy(); |
49 | } |
50 | |
51 | //! Initializes the current File Iterator |
52 | Standard_EXPORT void Initialize (const OSD_Path& where, const TCollection_AsciiString& Mask); |
53 | |
54 | //! Returns TRUE if there are other items using the 'Tree' |
55 | //! method. |
56 | Standard_EXPORT Standard_Boolean More(); |
57 | |
58 | //! Sets the iterator to the next item. |
59 | //! Returns the item value corresponding to the current |
60 | //! position of the iterator. |
61 | Standard_EXPORT void Next(); |
62 | |
63 | //! Returns the next file found . |
64 | Standard_EXPORT OSD_File Values(); |
65 | |
66 | //! Returns TRUE if an error occurs |
67 | Standard_EXPORT Standard_Boolean Failed() const; |
68 | |
69 | //! Resets error counter to zero |
70 | Standard_EXPORT void Reset(); |
71 | |
72 | //! Raises OSD_Error |
73 | Standard_EXPORT void Perror(); |
74 | |
75 | //! Returns error number if 'Failed' is TRUE. |
76 | Standard_EXPORT Standard_Integer Error() const; |
77 | |
42cf5bc1 |
78 | private: |
79 | |
42cf5bc1 |
80 | OSD_File TheIterator; |
dde68833 |
81 | Standard_Boolean myFlag; |
42cf5bc1 |
82 | TCollection_AsciiString myMask; |
83 | TCollection_AsciiString myPlace; |
42cf5bc1 |
84 | OSD_Error myError; |
d48df25d |
85 | |
86 | // platform-specific fields |
87 | #ifdef _WIN32 |
42cf5bc1 |
88 | Standard_Address myHandle; |
89 | Standard_Address myData; |
90 | Standard_Boolean myFirstCall; |
d48df25d |
91 | #else |
92 | Standard_Address myDescr; |
93 | Standard_Address myEntry; |
94 | Standard_Integer myInit; |
95 | #endif |
42cf5bc1 |
96 | }; |
97 | |
42cf5bc1 |
98 | #endif // _OSD_FileIterator_HeaderFile |