Oops, my fix to subdir.mk didn't work with existing symlinks. Fixed.
[wvapps.git] / wvsync / wvsyncfile.h
blob6065dc9af50b1600d2a874ef8c2860e40c64a573
1 /*
2 * Worldvisions Weaver Software:
3 * Copyright (C) 1997-2004 Net Integration Technologies, Inc.
5 * WvSyncFile provides the WvSyncObj implementation necessarily to
6 * conduct librsync operations on a standard file.
8 * Note that I use the regular ::open() and ::read() calls, rather than
9 * using WvFile, because I don't need or particularly want the buffer, and
10 * I need to be able to lseek().
13 #ifndef __WVSYNCFILE_H
14 #define __WVSYNCFILE_H
16 #include "wvsyncobj.h"
18 class WvSyncFile : public WvSyncObj
20 public:
21 WvSyncFile(WvStringParm _name, WvStringParm _rootdir);
23 virtual bool isok() const
24 { return ok; }
26 virtual time_t findlastmodtime() const;
28 /** metadata for WvSyncFile looks like this:
29 * mode uidname uid gidname gid
30 * eg:
31 * 49152:dcoombs:1000:weaver:4242
33 virtual WvString findmeta();
34 virtual void applymeta(WvStringParm newmeta, time_t newmtime);
36 /** override isunchanged() to accommodate symlinks, where you can't
37 * change the mtime.
39 virtual bool isunchanged(time_t sometime, WvStringParm somemeta) const;
41 /** issyncable() should return true for a regular file, a symlink, or a
42 * directory, and false for everything else. If the file doesn't
43 * exist, we can still sync it down, so check for that too.
45 virtual bool issyncable() const
46 { return S_ISREG(mode) || S_ISLNK(mode) || S_ISDIR(mode) || mode<0; }
48 virtual void makecopy(WvStringParm newname) const;
50 virtual bool isdir() const;
51 virtual bool isdir(WvStringParm somemeta) const;
53 virtual bool installnew(WvStringParm fname, WvStringParm newmeta,
54 time_t newmtime);
56 private:
57 WvString rootdir;
58 int fd;
59 off_t myofs;
60 bool ok;
62 time_t mtime;
63 mode_t mode;
64 off_t size;
65 uid_t uid;
66 gid_t gid;
68 virtual bool getdata(WvBuf &out, off_t ofs, size_t size);
70 virtual off_t approxsize() const;
72 WvString realname() const
73 { return WvString("%s/%s", rootdir, name); }
76 #endif // __WVSYNCFILE_H