/indra/llvfs/lldiriterator.h

https://bitbucket.org/lindenlab/viewer-beta/ · C++ Header · 87 lines · 14 code · 7 blank · 66 comment · 0 complexity · 67207d27bea3efc6379636242ccd1c5b MD5 · raw file

  1. /**
  2. * @file lldiriterator.h
  3. * @brief Iterator through directory entries matching the search pattern.
  4. *
  5. * $LicenseInfo:firstyear=2010&license=viewerlgpl$
  6. * Second Life Viewer Source Code
  7. * Copyright (C) 2010, Linden Research, Inc.
  8. *
  9. * This library is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation;
  12. * version 2.1 of the License only.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. *
  23. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  24. * $/LicenseInfo$
  25. */
  26. #ifndef LL_LLDIRITERATOR_H
  27. #define LL_LLDIRITERATOR_H
  28. #include "linden_common.h"
  29. /**
  30. * Class LLDirIterator
  31. *
  32. * Iterates through directory entries matching the search pattern.
  33. */
  34. class LLDirIterator
  35. {
  36. public:
  37. /**
  38. * Constructs LLDirIterator object to search for glob pattern
  39. * matches in a directory.
  40. *
  41. * @param dirname - name of a directory to search in.
  42. * @param mask - search pattern, a glob expression
  43. *
  44. * Wildcards supported in glob expressions:
  45. * --------------------------------------------------------------
  46. * | Wildcard | Matches |
  47. * --------------------------------------------------------------
  48. * | * |zero or more characters |
  49. * | ? |exactly one character |
  50. * | [abcde] |exactly one character listed |
  51. * | [a-e] |exactly one character in the given range |
  52. * | [!abcde] |any character that is not listed |
  53. * | [!a-e] |any character that is not in the given range |
  54. * | {abc,xyz} |exactly one entire word in the options given |
  55. * --------------------------------------------------------------
  56. */
  57. LLDirIterator(const std::string &dirname, const std::string &mask);
  58. ~LLDirIterator();
  59. /**
  60. * Searches for the next directory entry matching the glob mask
  61. * specified upon iterator construction.
  62. * Returns true if a match is found, sets fname
  63. * parameter to the name of the matched directory entry and
  64. * increments the iterator position.
  65. *
  66. * Typical usage:
  67. * <code>
  68. * LLDirIterator iter(directory, pattern);
  69. * if ( iter.next(scanResult) )
  70. * </code>
  71. *
  72. * @param fname - name of the matched directory entry.
  73. * @return true if a match is found, false otherwise.
  74. */
  75. bool next(std::string &fname);
  76. protected:
  77. class Impl;
  78. Impl* mImpl;
  79. };
  80. #endif //LL_LLDIRITERATOR_H