MCPcopy Create free account
hub / github.com/bailey27/cppcryptfs / lookup

Method lookup

libcppcryptfs/filename/longfilenamecache.cpp:113–174  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

111
112
113bool LongFilenameCache::lookup(LPCWSTR base64_hash, wstring *path, string *actual_encrypted)
114{
115
116 const WCHAR *key = base64_hash;
117
118 bool found;
119
120 lock();
121
122 m_lookups++;
123
124 auto it = m_map.find(key);
125
126 if (it != m_map.end()) {
127
128 LongFilenameCacheNode *node = it->second;
129
130 if (check_node_clean(node, key)) {
131
132 // The entry not stale, so use it.
133
134 if (path)
135 *path = node->m_path;
136 if (actual_encrypted)
137 *actual_encrypted = node->m_actual_encrypted;
138
139 // if node isn't already at front of list, remove
140 // it from wherever it was and put it at the front
141
142 if (node->m_list_it != m_lru_list.begin()) {
143 m_lru_list.erase(node->m_list_it);
144 m_lru_list.push_front(node);
145 node->m_list_it = m_lru_list.begin();
146 }
147 found = true;
148 m_hits++;
149
150 } else {
151
152 // The entry is no longer valid. Remove it, add it to the spare list, and return a miss.
153
154 m_map.erase(it);
155
156 m_lru_list.erase(node->m_list_it);
157
158 m_spare_node_list.push_front(node);
159
160 found = false;
161 }
162 } else {
163 found = false;
164 }
165
166 if (m_lookups && (m_lookups % 1024 == 0)) {
167 double ratio = (double)m_hits / (double)m_lookups;
168 //DbgPrint(L"LongFilenameCache: %I64d lookups, %I64d hits, %I64d misses, hit ratio %0.2f%%\n", m_lookups, m_hits, m_lookups - m_hits, ratio*100);
169 }
170

Callers

nothing calls this directly

Calls 2

findMethod · 0.80
eraseMethod · 0.80

Tested by

no test coverage detected