(file) Return to Dir.h CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2