1 // -*- mode: cpp; mode: fold -*-
3 // $Id: dsync-flist.h,v 1.5 1999/12/26 06:59:00 jgg Exp $
4 /* ######################################################################
6 Some header declarations..
8 ##################################################################### */
14 #pragma interface "dsync-flist.h"
17 #include <dsync/genfilelist.h>
18 #include <dsync/fileutl.h>
19 #include <dsync/filelistdb.h>
20 #include <dsync/compare.h>
30 extern ofstream devnull;
31 extern unsigned int ScreenWidth;
33 class FdIO : public dsFList::IO
38 virtual bool Read(void *Buf,unsigned long Len) {return Fd.Read(Buf,Len);};
39 virtual bool Write(const void *Buf,unsigned long Len) {return Fd.Write(Buf,Len);};
40 virtual bool Seek(unsigned long Bytes) {return Fd.Seek(Bytes);};
41 virtual unsigned long Tell() {return Fd.Tell();};
43 FdIO(string File,FileFd::OpenMode Mode) : Fd(File,Mode) {};
56 unsigned long DirCount;
57 unsigned long FileCount;
58 unsigned long LinkCount;
59 unsigned long LastCount;
62 struct timeval StartTime;
66 void Update(const char *Dir);
72 c0out << '\r' << BlankLine << '\r';
77 c0out << LastLine << '\r' << flush;
81 ~Progress() {Done();};
84 class ListGenerator : public dsGenFileList
89 unsigned long MinRSyncSize;
90 unsigned int StripDepth;
92 virtual int Visit(const char *Directory,const char *File,
93 struct stat const &Stat);
94 virtual bool EmitMD5(const char *Dir,const char *File,
95 struct stat const &St,unsigned char MD5[16],
96 unsigned int Tag,unsigned int Flag);
97 virtual bool NeedsRSync(const char *Dir,const char *File,
98 dsFList::NormalFile &F);
107 dsFileFilter RemoveFilter;
108 dsFileFilter RSyncFilter;
114 class Compare : public dsDirCorrect
122 virtual bool Visit(dsFList &List,string Dir);
123 void PrintPath(ostream &out,string Dir,string Name);
125 // Display status information
126 virtual bool GetNew(dsFList &List,string Dir)
130 PrintPath(c1out,Dir,List.Entity->Name);
132 return !Act || dsDirCorrect::GetNew(List,Dir);
134 virtual bool Delete(string Dir,const char *Name,bool Now = false)
138 PrintPath(c1out,Dir,Name);
140 return !Act || !DoDelete || dsDirCorrect::Delete(Dir,Name);
142 virtual bool GetChanged(dsFList &List,string Dir)
146 PrintPath(c1out,Dir,List.Entity->Name);
148 return !Act || dsDirCorrect::GetChanged(List,Dir);
150 virtual bool SetTime(dsFList &List,string Dir)
152 if (Verbose == false)
153 return !Act || dsDirCorrect::SetTime(List,Dir);
157 PrintPath(c1out,Dir,List.Entity->Name);
159 return !Act || dsDirCorrect::SetTime(List,Dir);
161 virtual bool SetPerm(dsFList &List,string Dir)
163 if (Verbose == false)
164 return !Act || dsDirCorrect::SetPerm(List,Dir);
167 PrintPath(c1out,Dir,List.Entity->Name);
169 return !Act || dsDirCorrect::SetPerm(List,Dir);
171 virtual bool SetOwners(dsFList &List,string Dir)
173 if (Verbose == false)
174 return !Act || dsDirCorrect::SetOwners(List,Dir);
177 PrintPath(c1out,Dir,List.Entity->Name);
179 return !Act || dsDirCorrect::SetOwners(List,Dir);
181 virtual bool CheckHash(dsFList &List,string Dir,unsigned char MD5[16])
183 Prog.CkSumBytes += List.File->Size;
189 PrintPath(c1out,Dir,List.Entity->Name);
192 return dsDirCompare::CheckHash(List,Dir,MD5);
203 bool SimplifyPath(char *Buffer);
204 bool ResolveLink(char *Buffer,unsigned long Max);