7 #include "unimountgen.h"
11 #include "unilistiter.h"
12 #include "wvstringtable.h"
36 if (has_subkey(key, NULL))
39 return WvString::null;
42 return found->gen->get(trimkey(found->key, key));
51 found->gen->set(trimkey(found->key, key), value);
59 UniConfPairList pairs;
72 UniGenMountPairsDict mountpairs(mounts.count());
75 MountList::Iter m(mounts);
76 for (m.rewind(); m.next(); )
81 UniConfPairList::Iter pair(pairs);
82 for (pair.rewind(); pair.next(); )
90 mountpairs[found->key]->pairs.add(trimmed,
true);
94 UniGenMountPairsDict::Iter i(mountpairs);
95 for (i.rewind(); i.next(); )
96 i->mount->gen->setv(i->pairs);
104 if (found && found->gen->exists(trimkey(found->key, key)))
109 return has_subkey(key, found);
117 if (found && found->gen->haschildren(trimkey(found->key, key)))
123 return has_subkey(key, found);
127 bool UniMountGen::has_subkey(
const UniConfKey &key, UniGenMount *found)
129 MountList::Iter i(mounts);
130 for (i.rewind(); i.next(); )
132 if (key.
suborsame(i->key) && key < i->key)
141 if (found && (i->gen == found->gen))
155 MountList::Iter i(mounts);
156 for (i.rewind(); i.next(); )
157 result = result && i->gen->refresh();
168 MountList::Iter i(mounts);
169 for (i.rewind(); i.next();)
183 assert(gen &&
"Moniker doesn't get us a generator!");
185 if (gen && !gen->
exists(
"/"))
198 gen->
add_callback(
this, wv::bind(&UniMountGen::gencallback,
this,
199 newgen->key, _1, _2));
209 mounts.prepend(newgen,
true);
211 delta(key,
get(key));
224 MountList::Iter i(mounts);
226 for (i.rewind(); i.next() && i->gen != gen; )
251 for (i.rewind(); i.next() && i->gen != next; )
253 if (key.
suborsame(i->key) && key != i->key)
256 delta(i->key,
get(i->key));
264 void UniMountGen::zap()
266 while (!mounts.isempty())
267 unmount(mounts.first()->gen,
false);
274 MountList::Iter i(mounts);
276 for (i.rewind(); i.next(); )
278 if (i->key.suborsame(key))
281 *mountpoint = i->key;
292 MountList::Iter i(mounts);
294 for (i.rewind(); i.next(); )
305 return strcmp(*l, *r);
312 return found->gen->iterator(trimkey(found->key, key));
320 MountList::Iter i(mounts);
322 for (i.rewind(); i.next(); )
336 WvStringTable::Sorter s(t, &::wvstrcmp);
337 for (s.rewind(); s.next();)
352 return found->gen->recursiveiterator(trimkey(found->key, key));
361 MountList::Iter i(mounts);
362 for (i.rewind(); i.next(); )
364 if (i->key.suborsame(key))
375 int num_found_mounts = 0;
378 MountList::Iter i(mounts);
379 for (i.rewind(); i.next(); )
382 if (i->key.suborsame(key) && !foundmount)
384 foundmount = i.ptr();
394 if (num_found_mounts == 1 && foundmount)
408 void UniMountGen::makemount(
const UniConfKey &key)
415 for (i.rewind(); i.next(); )
418 if (
get(points).isnull())
425 UniGenMount *found = findmount(points.
removelast());
429 if (found->gen->get(trimkey(found->key, key)).isnull())
430 found->gen->set(trimkey(found->key, key),
"");