diff options
author | Nathan Woods <npwoods@mess.org> | 2016-06-24 06:54:56 -0400 |
---|---|---|
committer | Nathan Woods <npwoods@mess.org> | 2016-06-24 07:13:18 -0400 |
commit | cd8b414e6bc14b375dcf2a4eb17eb0353926474f (patch) | |
tree | 56d43f4241b29097822583e00fa938d63fe1f5ac /src/osd/osdcore.h | |
parent | c96215487573733e7250e76524b95de43e8bef8e (diff) |
C++-ified osd_directory (now osd::directory), and added last_modified to osd::directory::entry
Diffstat (limited to 'src/osd/osdcore.h')
-rw-r--r-- | src/osd/osdcore.h | 127 |
1 files changed, 58 insertions, 69 deletions
diff --git a/src/osd/osdcore.h b/src/osd/osdcore.h index c712b3fea8e..85672445196 100644 --- a/src/osd/osdcore.h +++ b/src/osd/osdcore.h @@ -25,6 +25,7 @@ #include <cstdint> #include <memory> #include <string> +#include <chrono> /*************************************************************************** @@ -297,78 +298,66 @@ int osd_uchar_from_osdchar(UINT32 /* unicode_char */ *uchar, const char *osdchar DIRECTORY INTERFACES ***************************************************************************/ -/* types of directory entries that can be returned */ -enum osd_dir_entry_type +namespace osd { - ENTTYPE_NONE, - ENTTYPE_FILE, - ENTTYPE_DIR, - ENTTYPE_OTHER -}; - -/* osd_directory is an opaque type which represents an open directory */ -struct osd_directory; - -/* osd_directory_entry contains basic information about a file when iterating through */ -/* a directory */ -struct osd_directory_entry -{ - const char * name; /* name of the entry */ - osd_dir_entry_type type; /* type of the entry */ - UINT64 size; /* size of the entry */ + // directory is an opaque type which represents an open directory + class directory + { + public: + // osd::directory::entry contains basic information about a file when iterating through + // a directory + class entry + { + public: + enum class entry_type + { + NONE, + FILE, + DIR, + OTHER + }; + + const char * name; // name of the entry + entry_type type; // type of the entry + UINT64 size; // size of the entry + std::chrono::system_clock::time_point last_modified; // last modified time + }; + + // ----------------------------------------------------------------------------- + // osd::directory::open: open a directory for iteration + // + // Parameters: + // + // dirname - path to the directory in question + // + // Return value: + // + // upon success, this function should return an directory pointer + // which contains opaque data necessary to traverse the directory; on + // failure, this function should return nullptr + // ----------------------------------------------------------------------------- + static directory *open(const char *dirname); + + // ----------------------------------------------------------------------------- + // osd::directory::~directory: close an open directory + // ----------------------------------------------------------------------------- + virtual ~directory() { } + + // ----------------------------------------------------------------------------- + // osd::directory::read: return information about the next entry in the directory + // + // Return value: + // + // a constant pointer to an entry representing the current item + // in the directory, or nullptr, indicating that no more entries are + // present + // ----------------------------------------------------------------------------- + virtual const entry *read() = 0; + }; }; /*----------------------------------------------------------------------------- - osd_opendir: open a directory for iteration - - Parameters: - - dirname - path to the directory in question - - Return value: - - upon success, this function should return an osd_directory pointer - which contains opaque data necessary to traverse the directory; on - failure, this function should return nullptr ------------------------------------------------------------------------------*/ -osd_directory *osd_opendir(const char *dirname); - - -/*----------------------------------------------------------------------------- - osd_readdir: return information about the next entry in the directory - - Parameters: - - dir - pointer to an osd_directory that was returned from a prior - call to osd_opendir - - Return value: - - a constant pointer to an osd_directory_entry representing the current item - in the directory, or nullptr, indicating that no more entries are - present ------------------------------------------------------------------------------*/ -const osd_directory_entry *osd_readdir(osd_directory *dir); - - -/*----------------------------------------------------------------------------- - osd_closedir: close an open directory for iteration - - Parameters: - - dir - pointer to an osd_directory that was returned from a prior - call to osd_opendir - - Return value: - - frees any allocated memory and resources associated with the open - directory ------------------------------------------------------------------------------*/ -void osd_closedir(osd_directory *dir); - - -/*----------------------------------------------------------------------------- osd_is_absolute_path: returns whether the specified path is absolute Parameters: @@ -798,12 +787,12 @@ char *osd_get_clipboard_text(void); Return value: - an allocated pointer to an osd_directory_entry representing + an allocated pointer to an osd::directory::entry representing info on the path; even if the file does not exist. free with osd_free() -----------------------------------------------------------------------------*/ -osd_directory_entry *osd_stat(std::string const &path); +osd::directory::entry *osd_stat(std::string const &path); /*************************************************************************** PATH INTERFACES |