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

Method lookup

libcppcryptfs/filename/casecache.cpp:297–372  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

295
296
297int CaseCache::lookup(LPCWSTR path, wstring& result_path, bool force_not_found)
298{
299
300 if (!wcscmp(path, L"\\") || !wcscmp(path, L"\\*")) {
301 result_path = path;
302 return CASE_CACHE_FOUND;
303 }
304
305 int ret;
306
307 wstring dir;
308 wstring file;
309
310 if (!get_dir_and_file_from_path(path, &dir, &file))
311 return CASE_CACHE_ERROR;
312
313 wstring ucdir;
314 wstring ucfile;
315
316 if (!touppercase(dir.c_str(), ucdir))
317 return CASE_CACHE_ERROR;
318
319 wstring file_without_stream;
320 wstring stream;
321
322 get_file_stream(file.c_str(), &file_without_stream, &stream);
323
324 if (!touppercase(file_without_stream.c_str(), ucfile))
325 return CASE_CACHE_ERROR;
326
327 lock();
328
329 m_lookups++;
330
331 try {
332
333 auto it = m_map.find(ucdir);
334
335 if (it == m_map.end()) {
336 ret = CASE_CACHE_MISS;
337 } else {
338
339 CaseCacheNode *node = it->second;
340
341 if (!check_node_clean(node)) {
342 remove_node(it);
343 ret = CASE_CACHE_MISS;
344 } else {
345
346 update_lru(node);
347
348 auto nit = force_not_found ? node->m_files.end() : node->m_files.find(ucfile);
349
350 bool isRoot = wcscmp(node->m_path.c_str(), L"\\") == 0;
351
352 if (nit != node->m_files.end()) {
353 result_path = node->m_path + (isRoot ? L"" : L"\\") + nit->second + stream;
354 ret = CASE_CACHE_FOUND;

Callers 6

ConvertMethod · 0.45
get_dir_ivFunction · 0.45
decrypt_reverse_longnameFunction · 0.45
decrypt_pathFunction · 0.45
unencrypt_pathFunction · 0.45
get_actual_encryptedFunction · 0.45

Calls 4

touppercaseFunction · 0.85
get_file_streamFunction · 0.85
findMethod · 0.80

Tested by

no test coverage detected