| 1 |
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying |
| 2 |
file Copyright.txt or https://cmake.org/licensing#kwsys for details. */ |
| 3 |
#ifndef @KWSYS_NAMESPACE@_Directory_hxx |
| 4 |
#define @KWSYS_NAMESPACE@_Directory_hxx |
| 5 |
|
| 6 |
#include <@KWSYS_NAMESPACE@/Configure.h> |
| 7 |
#include <@KWSYS_NAMESPACE@/Status.hxx> |
| 8 |
|
| 9 |
#include <cstddef> |
| 10 |
#include <string> |
| 11 |
|
| 12 |
namespace @KWSYS_NAMESPACE@ { |
| 13 |
|
| 14 |
class DirectoryInternals; |
| 15 |
|
| 16 |
/** \class Directory |
| 17 |
* \brief Portable directory/filename traversal. |
| 18 |
* |
| 19 |
* Directory provides a portable way of finding the names of the files |
| 20 |
* in a system directory. |
| 21 |
* |
| 22 |
* Directory currently works with Windows and Unix operating systems. |
| 23 |
*/ |
| 24 |
class @KWSYS_NAMESPACE@_EXPORT Directory |
| 25 |
{ |
| 26 |
public: |
| 27 |
Directory(); |
| 28 |
Directory(Directory&& other); |
| 29 |
Directory(const Directory&) = delete; |
| 30 |
Directory& operator=(const Directory&) = delete; |
| 31 |
Directory& operator=(Directory&& other); |
| 32 |
bool operator==(const Directory&) = delete; |
| 33 |
~Directory(); |
| 34 |
|
| 35 |
/** |
| 36 |
* Load the specified directory and load the names of the files |
| 37 |
* in that directory. |
| 38 |
*/ |
| 39 |
Status Load(std::string const&, std::string* errorMessage = nullptr); |
| 40 |
|
| 41 |
/** |
| 42 |
* Return the number of files in the current directory. |
| 43 |
*/ |
| 44 |
unsigned long GetNumberOfFiles() const; |
| 45 |
|
| 46 |
/** |
| 47 |
* Return the number of files in the specified directory. |
| 48 |
* A higher performance static method. |
| 49 |
*/ |
| 50 |
static unsigned long GetNumberOfFilesInDirectory( |
| 51 |
const std::string&, std::string* errorMessage = nullptr); |
| 52 |
|
| 53 |
/** |
| 54 |
* Return the file at the given index, the indexing is 0 based |
| 55 |
*/ |
| 56 |
const char* GetFile(unsigned long) const; |
| 57 |
|
| 58 |
/** |
| 59 |
* Return the name of the file at the given 0-based index. |
| 60 |
*/ |
| 61 |
std::string const& GetFileName(std::size_t i) const; |
| 62 |
|
| 63 |
/** |
| 64 |
* Return the absolute path to the file at the given 0-based index. |
| 65 |
*/ |
| 66 |
std::string GetFilePath(std::size_t i) const; |
| 67 |
|
| 68 |
/** |
| 69 |
* Return whether the file at the given 0-based index is a directory. |
| 70 |
*/ |
| 71 |
bool FileIsDirectory(std::size_t i) const; |
| 72 |
|
| 73 |
/** |
| 74 |
* Return whether the file at the given 0-based index is a symlink. |
| 75 |
*/ |
| 76 |
bool FileIsSymlink(std::size_t i) const; |
| 77 |
|
| 78 |
/** |
| 79 |
* Return the path to Open'ed directory |
| 80 |
*/ |
| 81 |
const char* GetPath() const; |
| 82 |
|
| 83 |
/** |
| 84 |
* Clear the internal structure. Used internally at beginning of Load(...) |
| 85 |
* to clear the cache. |
| 86 |
*/ |
| 87 |
void Clear(); |
| 88 |
|
| 89 |
private: |
| 90 |
// Private implementation details. |
| 91 |
DirectoryInternals* Internal; |
| 92 |
}; // End Class: Directory |
| 93 |
|
| 94 |
} // namespace @KWSYS_NAMESPACE@ |
| 95 |
|
| 96 |
#endif |