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

 1 mike  1.3 //%/////////////////////////////////////////////////////////////////////////////
 2 mike  1.1 //
 3           // Copyright (c) 2000 The Open Group, BMC Software, Tivoli Systems, IBM
 4           //
 5           // Permission is hereby granted, free of charge, to any person obtaining a
 6           // copy of this software and associated documentation files (the "Software"),
 7           // to deal in the Software without restriction, including without limitation
 8           // the rights to use, copy, modify, merge, publish, distribute, sublicense,
 9           // and/or sell copies of the Software, and to permit persons to whom the
10           // Software is furnished to do so, subject to the following conditions:
11           //
12           // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13           // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14           // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
15           // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16           // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
17           // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
18           // DEALINGS IN THE SOFTWARE.
19           //
20 mike  1.3 //==============================================================================
21 mike  1.1 //
22 mike  1.3 // Author: Mike Brasher (mbrasher@bmc.com)
23 mike  1.1 //
24 mike  1.3 // Modified By:
25 mike  1.2 //
26 mike  1.3 //%/////////////////////////////////////////////////////////////////////////////
27 mike  1.1 
28           #include "Destroyer.h"
29           #include "Dir.h"
30           #include "Exception.h"
31           
32           PEGASUS_NAMESPACE_BEGIN
33           
34           #include <io.h>
35           #include <direct.h>
36           
37           struct DirRep
38           {
39               long file;
40               struct _finddata_t findData;
41           };
42           
43           Dir::Dir(const String& path)
44           {
45 mike  1.2     ArrayDestroyer<char> p(strcat(path.allocateCString(2), "/*"));
46 mike  1.1     _rep = new DirRep;
47               _rep->file = _findfirst(p.getPointer(), &_rep->findData);
48           
49               if (_rep->file == -1)
50               {
51           	_more = false;
52           	throw CannotOpenDirectory(path);
53               }
54               else
55           	_more = true;
56           }
57           
58           Dir::~Dir()
59           {
60               if (_rep->file != -1)
61           	_findclose(_rep->file);
62           
63               delete _rep;
64           }
65           
66           const char* Dir::getName() const
67 mike  1.1 {
68               return _rep->findData.name;
69           }
70           
71           void Dir::next()
72           {
73               if (!_more)
74           	return;
75           
76               _more = _findnext(_rep->file, &_rep->findData) == 0;
77           }
78           
79           PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2