DirectoryIterator_VMS.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. //
  2. // DirectoryIterator_VMS.cpp
  3. //
  4. // $Id: //poco/1.4/Foundation/src/DirectoryIterator_VMS.cpp#1 $
  5. //
  6. // Library: Foundation
  7. // Package: Filesystem
  8. // Module: DirectoryIterator
  9. //
  10. // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
  11. // and Contributors.
  12. //
  13. // SPDX-License-Identifier: BSL-1.0
  14. //
  15. #include "Poco/DirectoryIterator_VMS.h"
  16. #include "Poco/Path.h"
  17. #include "Poco/Exception.h"
  18. #include <iodef.h>
  19. #include <atrdef.h>
  20. #include <fibdef.h>
  21. #include <starlet.h>
  22. namespace Poco {
  23. DirectoryIteratorImpl::DirectoryIteratorImpl(const std::string& path): _rc(1)
  24. {
  25. Path p(path);
  26. p.makeDirectory();
  27. _search = p.toString();
  28. _search.append("*.*;*");
  29. _fab = cc$rms_fab;
  30. _fab.fab$l_fna = (char*) _search.c_str();
  31. _fab.fab$b_fns = _search.size();
  32. _fab.fab$l_nam = &_nam;
  33. _nam = cc$rms_nam;
  34. _nam.nam$l_esa = _spec;
  35. _nam.nam$b_ess = sizeof(_spec);
  36. if (sys$parse(&_fab) & 1)
  37. throw OpenFileException(path);
  38. next();
  39. }
  40. DirectoryIteratorImpl::~DirectoryIteratorImpl()
  41. {
  42. }
  43. const std::string& DirectoryIteratorImpl::next()
  44. {
  45. if (sys$search(&_fab) & 1)
  46. _current.clear();
  47. else
  48. _current.assign(_fab.fab$l_nam->nam$l_name, _fab.fab$l_nam->nam$b_name + _fab.fab$l_nam->nam$b_type);
  49. return _current;
  50. }
  51. } // namespace Poco