00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #ifndef INCL_FILE_SYNC_SOURCE
00037 #define INCL_FILE_SYNC_SOURCE
00038
00042 #include "base/fscapi.h"
00043 #include "spds/constants.h"
00044 #include "spds/SyncItem.h"
00045 #include "spds/SyncMap.h"
00046 #include "spds/SyncStatus.h"
00047 #include "base/util/ItemContainer.h"
00048 #include "spds/FileData.h"
00049 #include "client/CacheSyncSource.h"
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062 BEGIN_NAMESPACE
00063
00064 #define DEFAULT_SYNC_DIR "."
00065
00079 class FileSyncSource : public CacheSyncSource {
00080
00081 protected:
00082 StringBuffer dir;
00083
00092 virtual bool filterOutgoingItem(const StringBuffer& fullName, struct stat& st);
00093
00100 bool checkFileExtension(const StringBuffer& fileName, const StringBuffer& extension);
00101
00102
00103 private:
00104
00106 bool recursive;
00107
00108
00109 FileSyncSource(const FileSyncSource& s) : CacheSyncSource(s){};
00110 FileSyncSource& operator=(const FileSyncSource& s) { return *this; };
00111
00112
00125 bool scanFolder(const StringBuffer& fullPath, ArrayList& filesFound, bool applyFiltering = true);
00126
00127
00128 public:
00129
00130 FileSyncSource(const WCHAR* name, AbstractSyncSourceConfig* sc,
00131 const StringBuffer& aDir = DEFAULT_SYNC_DIR,
00132 KeyValueStore* cache = NULL);
00133
00134 virtual ~FileSyncSource();
00135
00136 void assign(FileSyncSource& s);
00137
00141 void setDir(const char* p) { dir = p; }
00142 const StringBuffer& getDir() { return dir; };
00143
00147 void setRecursive(const bool value) { recursive = value; }
00148 const bool getRecursive() { return recursive; };
00149
00150
00155 virtual Enumeration* getAllItemList();
00156
00162 virtual int removeAllItems();
00163
00174 virtual int insertItem(SyncItem& item);
00175
00183 virtual int modifyItem(SyncItem& item);
00184
00192 virtual int removeItem(SyncItem& item);
00193
00203 virtual void* getItemContent(StringBuffer& key, size_t* size);
00204
00205
00206 };
00207
00208 END_NAMESPACE
00209
00212 #endif
00213