|
|
|
|
|
|
|
|
#include <ctime> |
|
|
#include <ctime> |
|
|
|
|
|
|
|
|
#include <string> |
|
|
#include <string> |
|
|
|
|
|
#include <vector> |
|
|
|
|
|
|
|
|
namespace CodeDweller { |
|
|
namespace CodeDweller { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
This method updates the FileReference object with the current |
|
|
This method updates the FileReference object with the current |
|
|
data on the file system, except for the full path. |
|
|
data on the file system, except for the full path. |
|
|
|
|
|
|
|
|
*/ |
|
|
*/ |
|
|
void refresh(); |
|
|
void refresh(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
|
*/ |
|
|
bool isDirectory() const; |
|
|
bool isDirectory() const; |
|
|
|
|
|
|
|
|
private: |
|
|
|
|
|
|
|
|
|
|
|
/// Return text for the most recent error. |
|
|
/// Return text for the most recent error. |
|
|
// |
|
|
// |
|
|
// \returns Human-readable description of the most recent error. |
|
|
// \returns Human-readable description of the most recent error. |
|
|
// |
|
|
// |
|
|
static std::string getErrorText(); |
|
|
static std::string getErrorText(); |
|
|
|
|
|
|
|
|
|
|
|
private: |
|
|
|
|
|
|
|
|
/// Reset all members but the name. */ |
|
|
/// Reset all members but the name. */ |
|
|
void reset(); |
|
|
void reset(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
/** Abstracts OS specifics for scanning a directory and provides |
|
|
|
|
|
access to meta data. |
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
class DirectoryReference : public std::vector<FileReference> { |
|
|
|
|
|
|
|
|
|
|
|
public: |
|
|
|
|
|
|
|
|
|
|
|
/** Initialize by scanning the directory. |
|
|
|
|
|
|
|
|
|
|
|
The constructor updates the DirectoryReference object with the |
|
|
|
|
|
listing of the specified directory, filtered by the specified |
|
|
|
|
|
function. |
|
|
|
|
|
|
|
|
|
|
|
@param[in] dirName is the name of the directory. |
|
|
|
|
|
|
|
|
|
|
|
@param[in] filter is the function used to filter the directory |
|
|
|
|
|
listing. It inputs the name of the file, and returns true if |
|
|
|
|
|
the file is is to be included in the listing, and false |
|
|
|
|
|
otherwise. |
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
DirectoryReference(std::string dirName, bool (*dirFilter)(std::string) = 0); |
|
|
|
|
|
|
|
|
|
|
|
/** Refreshes the DirectoryReference object. |
|
|
|
|
|
|
|
|
|
|
|
This method updates the DirectoryReference object with the |
|
|
|
|
|
current listing on the file system. |
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
void refresh(); |
|
|
|
|
|
|
|
|
|
|
|
private: |
|
|
|
|
|
|
|
|
|
|
|
/** Directory name provided to constructor. */ |
|
|
|
|
|
std::string name; |
|
|
|
|
|
|
|
|
|
|
|
/** Filter function. */ |
|
|
|
|
|
bool (*filter)(std::string); |
|
|
|
|
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
#endif // FILESYSTEM_HPP |
|
|
#endif // FILESYSTEM_HPP |