1 // -*- mode: cpp; mode: fold -*-
3 // $Id: compare.h,v 1.3 1999/01/17 22:00:51 jgg Exp $
4 /* ######################################################################
6 Compare a file list with a local directory
8 The Compare class looks at the file list and then generates events
9 to cause the local directory tree to become syncronized with the
12 The Correct class takes the events and applies them to the local tree.
13 It only applies information that is stored in the file list, another
14 class will have to hook the events to actually fetch files for download.
16 ##################################################################### */
22 #pragma interface "dsync/compare.h"
25 #include <dsync/filelist.h>
29 unsigned int IndexSize;
30 unsigned int IndexAlloc;
31 unsigned int *Indexes;
32 unsigned int NameAlloc;
37 // Location of the tree
42 bool DoDelete(string Dir);
43 bool Fetch(dsFList &List,string Dir,struct stat *St);
44 bool DirExists(string Name);
45 virtual bool CheckHash(dsFList &List,string Dir,unsigned char MD5[16]);
46 virtual bool FixMeta(dsFList &List,string Dir,struct stat &St);
47 virtual bool Visit(dsFList &List,string Dir) {return true;};
49 // Derived classes can hook these to actuall make them do something
50 virtual bool GetNew(dsFList &List,string Dir) {return true;};
51 virtual bool Delete(string Dir,const char *Name,bool Now = false) {return true;};
52 virtual bool GetChanged(dsFList &List,string Dir) {return true;};
53 virtual bool SetTime(dsFList &List,string Dir) {return true;};
54 virtual bool SetPerm(dsFList &List,string Dir) {return true;};
55 virtual bool SetOwners(dsFList &List,string Dir) {return true;};
60 enum {Md5Never, Md5Date, Md5Always} HashLevel;
62 bool Process(string Base,dsFList::IO &IO);
65 virtual ~dsDirCompare();
68 class dsDirCorrect : public dsDirCompare
70 bool DirUnlink(const char *Path);
74 // Derived classes can hook these to actuall make them do something
75 virtual bool GetNew(dsFList &List,string Dir);
76 virtual bool Delete(string Dir,const char *Name,bool Now = false);
77 virtual bool GetChanged(dsFList &List,string Dir);
78 virtual bool SetTime(dsFList &List,string Dir);
79 virtual bool SetPerm(dsFList &List,string Dir);
80 virtual bool SetOwners(dsFList &List,string Dir);