blob: da5ea4fcd3a23858309c56cfd00ff712bd9330b1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
//
// Copyright 2011 The Android Open Source Project
//
#ifndef MOCKFILEFINDER_H
#define MOCKFILEFINDER_H
#include <utils/Vector.h>
#include <utils/KeyedVector.h>
#include <utils/String8.h>
#include "DirectoryWalker.h"
using namespace android;
class MockFileFinder : public FileFinder {
public:
MockFileFinder (KeyedVector<String8, KeyedVector<String8,time_t> >& files)
: mFiles(files)
{
// Nothing left to do
};
/**
* findFiles implementation for the abstraction.
* PRECONDITIONS:
* No checking is done, so there MUST be an entry in mFiles with
* path matching basePath.
*
* POSTCONDITIONS:
* fileStore is filled with a copy of the data in mFiles corresponding
* to the basePath.
*/
virtual bool findFiles(String8 basePath, Vector<String8>& extensions,
KeyedVector<String8,time_t>& fileStore,
DirectoryWalker* dw)
{
const KeyedVector<String8,time_t>* payload(&mFiles.valueFor(basePath));
// Since KeyedVector doesn't implement swap
// (who doesn't use swap??) we loop and add one at a time.
for (size_t i = 0; i < payload->size(); ++i) {
fileStore.add(payload->keyAt(i),payload->valueAt(i));
}
return true;
}
private:
// Virtual mapping between "directories" and the "files" contained
// in them
KeyedVector<String8, KeyedVector<String8,time_t> > mFiles;
};
#endif // MOCKFILEFINDER_H
|