blob: 16be5051eabf7f8e36b62c9ec1e4b8bf97024671 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
//
// DirectoryIterator_UNIX.cpp
//
// Library: Foundation
// Package: Filesystem
// Module: DirectoryIterator
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/DirectoryIterator_UNIX.h"
#if defined(POCO_VXWORKS)
#include "Poco/File_VX.h"
#else
#include "Poco/File_UNIX.h"
#endif
#include "Poco/Path.h"
namespace Poco {
DirectoryIteratorImpl::DirectoryIteratorImpl(const std::string& path): _pDir(0), _rc(1)
{
Path p(path);
p.makeFile();
#if defined(POCO_VXWORKS)
_pDir = opendir(const_cast<char*>(p.toString().c_str()));
#else
_pDir = opendir(p.toString().c_str());
#endif
if (!_pDir) File::handleLastError(path);
next();
}
DirectoryIteratorImpl::~DirectoryIteratorImpl()
{
if (_pDir) closedir(_pDir);
}
const std::string& DirectoryIteratorImpl::next()
{
do
{
struct dirent* pEntry = readdir(_pDir);
if (pEntry)
_current = pEntry->d_name;
else
_current.clear();
}
while (_current == "." || _current == "..");
return _current;
}
} // namespace Poco
|