From fd0853d2623dd278b08288331ed42e3be59252fb Mon Sep 17 00:00:00 2001 From: Daniel Wilhelm Date: Fri, 18 Apr 2014 17:00:17 +0200 Subject: 2.2 --- shared/fileTraverser.h | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 shared/fileTraverser.h (limited to 'shared/fileTraverser.h') diff --git a/shared/fileTraverser.h b/shared/fileTraverser.h new file mode 100644 index 00000000..d2aa7f3e --- /dev/null +++ b/shared/fileTraverser.h @@ -0,0 +1,64 @@ +#ifndef FILETRAVERSER_H_INCLUDED +#define FILETRAVERSER_H_INCLUDED + +#include "zstring.h" +#include +#include +#include + +//advanced file traverser returning metadata and hierarchical information on files and directories + +namespace FreeFileSync +{ + class TraverseCallback + { + public: + virtual ~TraverseCallback() {} + + enum ReturnValue + { + TRAVERSING_STOP, + TRAVERSING_CONTINUE + }; + + struct FileInfo + { + wxULongLong fileSize; //unit: bytes! + wxLongLong lastWriteTimeRaw; //number of seconds since Jan. 1st 1970 UTC + }; + + class ReturnValDir + { + public: + //some proxy classes + class Stop {}; + class Ignore {}; + class Continue {}; + + ReturnValDir(const Stop&) : returnCode(TRAVERSING_STOP), subDirCb(NULL) {} + ReturnValDir(const Ignore&) : returnCode(TRAVERSING_IGNORE_DIR), subDirCb(NULL) {} + ReturnValDir(const Continue&, TraverseCallback* subDirCallback) : returnCode(TRAVERSING_CONTINUE), subDirCb(subDirCallback) {} + + + enum ReturnValueEnh + { + TRAVERSING_STOP, + TRAVERSING_IGNORE_DIR, + TRAVERSING_CONTINUE + }; + + const ReturnValueEnh returnCode; + TraverseCallback* const subDirCb; + }; + + //overwrite these virtual methods + virtual ReturnValue onError(const wxString& errorText) = 0; + virtual ReturnValue onFile(const DefaultChar* shortName, const Zstring& fullName, const FileInfo& details) = 0; + virtual ReturnValDir onDir(const DefaultChar* shortName, const Zstring& fullName) = 0; + }; + + //custom traverser with detail information about files + void traverseFolder(const Zstring& directory, const bool traverseDirectorySymlinks, TraverseCallback* sink); //throw() +} + +#endif // FILETRAVERSER_H_INCLUDED -- cgit