Added headers
[tpot/pegasus/.git] / src / Pegasus / Common / Dir.h
1 //%/////////////////////////////////////////////////////////////////////////////\r
2 //\r
3 // Copyright (c) 2000, 2001 The Open group, BMC Software, Tivoli Systems, IBM\r
4 //\r
5 // Permission is hereby granted, free of charge, to any person obtaining a copy\r
6 // of this software and associated documentation files (the "Software"), to \r
7 // deal in the Software without restriction, including without limitation the \r
8 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or \r
9 // sell copies of the Software, and to permit persons to whom the Software is\r
10 // furnished to do so, subject to the following conditions:\r
11 // \r
12 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN \r
13 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED\r
14 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT\r
15 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR \r
16 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT \r
17 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN \r
18 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
19 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
20 //\r
21 //==============================================================================\r
22 //\r
23 // Author: Mike Brasher (mbrasher@bmc.com)\r
24 //\r
25 // Modified By:\r
26 //\r
27 //%/////////////////////////////////////////////////////////////////////////////\r
28 \r
29 #ifndef Pegasus_Dir_h\r
30 #define Pegasus_Dir_h\r
31 \r
32 #include <Pegasus/Common/Config.h>\r
33 #include <Pegasus/Common/String.h>\r
34 #include <Pegasus/Common/Exception.h>\r
35 \r
36 PEGASUS_NAMESPACE_BEGIN\r
37 \r
38 struct DirRep;\r
39 \r
40 /** The Dir class provides a platform independent way of iterating the\r
41     files in a directory.\r
42 */\r
43 class PEGASUS_COMMON_LINKAGE Dir\r
44 {\r
45 public:\r
46 \r
47     /** Starts this iterator class on the given path.\r
48         @param String path is the path to the target directory \r
49         @return\r
50         @exception throws CannotOpenDirectory if invalid directory.\r
51 \r
52         <pre>\r
53         char* path = "."\r
54         try\r
55         { \r
56            for (Dir dir(path); dir.more(); dir.next())\r
57            {\r
58                cout << "name: " << dir.getName() << endl;\r
59            }\r
60         }\r
61         catch(CannotOpenDirectory&)\r
62         {\r
63            // Error!\r
64         }\r
65         </pre>\r
66     */\r
67     Dir(const String& path);\r
68 \r
69     /** Release any iterator resources. */\r
70     ~Dir();\r
71 \r
72     /** Return true if there are more file names to iterator. */\r
73     Boolean more() const { return _more; }\r
74 \r
75     /** Returns the current file name. */\r
76     const char* getName() const;\r
77 \r
78     /** Advance to next file in directory. */\r
79     void next();\r
80 \r
81 private:\r
82 \r
83     Boolean _more;\r
84     Boolean _isValid;\r
85     DirRep* _rep;\r
86 };\r
87 \r
88 PEGASUS_NAMESPACE_END\r
89 \r
90 #endif /* Pegasus_Dir_h */\r