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

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2