DirectoryIterator_UNIX.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. //
  2. // DirectoryIterator_UNIX.h
  3. //
  4. // Library: Foundation
  5. // Package: Filesystem
  6. // Module: DirectoryIterator
  7. //
  8. // Definition of the DirectoryIteratorImpl class for UNIX.
  9. //
  10. // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
  11. // and Contributors.
  12. //
  13. // SPDX-License-Identifier: BSL-1.0
  14. //
  15. #ifndef Foundation_DirectoryIterator_UNIX_INCLUDED
  16. #define Foundation_DirectoryIterator_UNIX_INCLUDED
  17. #include "Poco/Foundation.h"
  18. #include <dirent.h>
  19. namespace Poco {
  20. class Foundation_API DirectoryIteratorImpl
  21. {
  22. public:
  23. DirectoryIteratorImpl(const std::string& path);
  24. ~DirectoryIteratorImpl();
  25. void duplicate();
  26. void release();
  27. const std::string& get() const;
  28. const std::string& next();
  29. private:
  30. DIR* _pDir;
  31. std::string _current;
  32. int _rc;
  33. };
  34. //
  35. // inlines
  36. //
  37. const std::string& DirectoryIteratorImpl::get() const
  38. {
  39. return _current;
  40. }
  41. inline void DirectoryIteratorImpl::duplicate()
  42. {
  43. ++_rc;
  44. }
  45. inline void DirectoryIteratorImpl::release()
  46. {
  47. if (--_rc == 0)
  48. delete this;
  49. }
  50. } // namespace Poco
  51. #endif // Foundation_DirectoryIterator_UNIX_INCLUDED