]> git.decadent.org.uk Git - dak.git/blob - tools/dsync-0.0/libdsync/compare.h
LOCAL: Remove replay check
[dak.git] / tools / dsync-0.0 / libdsync / compare.h
1 // -*- mode: cpp; mode: fold -*-
2 // Description                                                          /*{{{*/
3 // $Id: compare.h,v 1.3 1999/01/17 22:00:51 jgg Exp $
4 /* ######################################################################
5    
6    Compare a file list with a local directory 
7    
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 
10    remote tree.
11    
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.
15    
16    ##################################################################### */
17                                                                         /*}}}*/
18 #ifndef DSYNC_COMPARE
19 #define DSYNC_COMPARE
20
21 #ifdef __GNUG__
22 #pragma interface "dsync/compare.h"
23 #endif 
24
25 #include <dsync/filelist.h>
26
27 class dsDirCompare
28 {
29    unsigned int IndexSize;
30    unsigned int IndexAlloc;
31    unsigned int *Indexes;
32    unsigned int NameAlloc;
33    char *Names;
34
35    protected:
36  
37    // Location of the tree
38    string Base;
39    
40    // Scan helpers
41    bool LoadDir();
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;};
48
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;};
56    
57    public:
58
59    bool Verify;
60    enum {Md5Never, Md5Date, Md5Always} HashLevel;
61    
62    bool Process(string Base,dsFList::IO &IO);
63    
64    dsDirCompare();
65    virtual ~dsDirCompare();
66 };
67
68 class dsDirCorrect : public dsDirCompare
69 {
70    bool DirUnlink(const char *Path);
71       
72    protected:
73
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);
81    
82    public:
83    
84 };
85
86 #endif