source: XMLIO_V2/external/src/POCO/Foundation/DirectoryIterator.cpp @ 80

Last change on this file since 80 was 80, checked in by ymipsl, 14 years ago

ajout lib externe

  • Property svn:eol-style set to native
File size: 4.1 KB
Line 
1//
2// DirectoryIterator.cpp
3//
4// $Id: //poco/1.3/Foundation/src/DirectoryIterator.cpp#2 $
5//
6// Library: Foundation
7// Package: Filesystem
8// Module:  DirectoryIteratls Dior
9//
10// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
11// and Contributors.
12//
13// Permission is hereby granted, free of charge, to any person or organization
14// obtaining a copy of the software and accompanying documentation covered by
15// this license (the "Software") to use, reproduce, display, distribute,
16// execute, and transmit the Software, and to prepare derivative works of the
17// Software, and to permit third-parties to whom the Software is furnished to
18// do so, all subject to the following:
19//
20// The copyright notices in the Software and this entire statement, including
21// the above license grant, this restriction and the following disclaimer,
22// must be included in all copies of the Software, in whole or in part, and
23// all derivative works of the Software, unless such copies or derivative
24// works are solely in the form of machine-executable object code generated by
25// a source language processor.
26//
27// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
28// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
29// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
30// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
31// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
32// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
33// DEALINGS IN THE SOFTWARE.
34//
35
36
37#include <Poco/DirectoryIterator.h>
38
39
40#if defined(POCO_OS_FAMILY_WINDOWS) && defined(POCO_WIN32_UTF8)
41#include "DirectoryIterator_WIN32U.hpp"
42#elif defined(POCO_OS_FAMILY_WINDOWS)
43#include "DirectoryIterator_WIN32.hpp"
44#elif defined(POCO_OS_FAMILY_UNIX)
45#include "DirectoryIterator_UNIX.hpp"
46#else
47#include "DirectoryIterator_VMS.hpp"
48#endif
49
50
51namespace Poco {
52
53
54DirectoryIterator::DirectoryIterator(): _pImpl(0)
55{
56}
57
58       
59DirectoryIterator::DirectoryIterator(const std::string& path): _path(path), _pImpl(new DirectoryIteratorImpl(path))
60{
61        _path.makeDirectory();
62        _path.setFileName(_pImpl->get());
63        _file = _path;
64}
65
66
67DirectoryIterator::DirectoryIterator(const DirectoryIterator& iterator): _path(iterator._path), _pImpl(iterator._pImpl)
68{
69        if (_pImpl) 
70        {
71                _pImpl->duplicate();
72                _file = _path;
73        }
74}
75
76       
77DirectoryIterator::DirectoryIterator(const File& file): _path(file.path()), _pImpl(new DirectoryIteratorImpl(file.path()))
78{
79        _path.makeDirectory();
80        _path.setFileName(_pImpl->get());
81        _file = _path;
82}
83
84
85DirectoryIterator::DirectoryIterator(const Path& path): _path(path), _pImpl(new DirectoryIteratorImpl(path.toString()))
86{
87        _path.makeDirectory();
88        _path.setFileName(_pImpl->get());
89        _file = _path;
90}
91
92
93DirectoryIterator::~DirectoryIterator()
94{
95        if (_pImpl) _pImpl->release();
96}
97
98
99DirectoryIterator& DirectoryIterator::operator = (const DirectoryIterator& it)
100{
101        if (_pImpl) _pImpl->release();
102        _pImpl = it._pImpl;
103        if (_pImpl) 
104        {
105                _pImpl->duplicate();
106                _path = it._path;
107                _file = _path;
108        }
109        return *this;
110}
111
112
113DirectoryIterator& DirectoryIterator::operator = (const File& file)
114{
115        if (_pImpl) _pImpl->release();
116        _pImpl = new DirectoryIteratorImpl(file.path());
117        _path.parseDirectory(file.path());
118        _path.setFileName(_pImpl->get());
119        _file = _path;
120        return *this;
121}
122
123
124DirectoryIterator& DirectoryIterator::operator = (const Path& path)
125{
126        if (_pImpl) _pImpl->release();
127        _pImpl = new DirectoryIteratorImpl(path.toString());
128        _path = path;
129        _path.makeDirectory();
130        _path.setFileName(_pImpl->get());
131        _file = _path;
132        return *this;
133}
134
135
136DirectoryIterator& DirectoryIterator::operator = (const std::string& path)
137{
138        if (_pImpl) _pImpl->release();
139        _pImpl = new DirectoryIteratorImpl(path);
140        _path.parseDirectory(path);
141        _path.setFileName(_pImpl->get());
142        _file = _path;
143        return *this;
144}
145
146
147DirectoryIterator& DirectoryIterator::operator ++ ()
148{
149        if (_pImpl)
150        {
151                _path.setFileName(_pImpl->next());
152                _file = _path;
153        }
154        return *this;
155}
156
157
158DirectoryIterator DirectoryIterator::operator ++ (int dummy)
159{
160        if (_pImpl)
161        {
162                _path.setFileName(_pImpl->next());
163                _file = _path;
164        }
165        return *this;
166}
167
168
169} // namespace Poco
Note: See TracBrowser for help on using the repository browser.