WvDBusMsg::is_reply() had an unnecessary hack for message #1.
[wvapps.git] / wvsync / wvsyncfilelister.cc
blob9d434c26f434e73f760eb128df95ace78ef5e710
1 /*
2 * Worldvisions Weaver Software:
3 * Copyright (C) 1997-2004 Net Integration Technologies, Inc.
5 * See wvsyncfilelister.h for details.
7 */
9 #include "wvsyncfilelister.h"
10 #include "wvsyncprotocol.h"
12 WvSyncFileLister::WvSyncFileLister(WvSyncProtocol &_prot,
13 WvStringParm _rootdir, UniConf _root)
14 : WvSyncLister(_prot),
15 log("FileLister", WvLog::Debug1),
16 err(log.split(WvLog::Error)),
17 rootdir(_rootdir),
18 root(_root),
19 i(_rootdir),
20 curdir("(nil)")
22 log(WvLog::Debug3, "FileLister created on %s\n", rootdir);
23 i.rewind();
24 chdir_coming = false;
28 WvSyncObj *WvSyncFileLister::next()
30 if (chdir_coming)
32 if (curdir != prot.getcwd())
33 do_chdir(curdir);
34 chdir_coming = false;
37 if (!i.next())
38 return NULL;
40 // Get the current reldir
41 WvString reldir = i->relname;
42 reldir.edit()[strlen(i->relname)-strlen(i->name)] = '\0';
43 int n = strlen(reldir);
44 while (reldir[--n] == '/')
45 reldir.edit()[n] = '\0';
47 if (!reldir)
48 reldir = ".";
49 if (prot.getcwd() != reldir)
51 curdir = reldir;
52 prot.do_yourturn();
53 chdir_coming = true;
56 // FIXME: do we leak this?
57 return new WvSyncFile(i->relname, rootdir);
61 WvSyncObj *WvSyncFileLister::makeobj(WvStringParm name)
63 // FIXME: do we leak this?
64 return new WvSyncFile(name, rootdir);
68 bool WvSyncFileLister::newcwd(WvStringParm dir)
70 curdir = dir;
71 log(WvLog::Debug3, "WvSyncFileLister::newcwd got dir:%s\n", dir);
72 return true;