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

Function find_files

libcppcryptfs/util/fileutil.cpp:311–421  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

309
310#ifdef _WIN32
311DWORD
312find_files(CryptContext *con, const WCHAR *pt_path, const WCHAR *path, PCryptFillFindData fillData, void * dokan_cb, void * dokan_ctx)
313{
314 DWORD ret = 0;
315 HANDLE hfind = INVALID_HANDLE_VALUE;
316
317 bool reverse = con->GetConfig()->m_reverse;
318
319 bool plaintext_names = con->GetConfig()->m_PlaintextNames;
320
321 KeyDecryptor kdc(plaintext_names ? nullptr : &con->GetConfig()->m_keybuf_manager);
322
323 list<wstring> files; // used only if case-insensitive
324
325 try {
326
327 wstring enc_path_search = path;
328
329 WIN32_FIND_DATAW fdata, fdata_dot;
330
331 if (enc_path_search[enc_path_search.size() - 1] != '\\')
332 enc_path_search.push_back('\\');
333
334 enc_path_search.push_back('*');
335
336 hfind = FindFirstFile(&enc_path_search[0], &fdata);
337
338 if (hfind == INVALID_HANDLE_VALUE)
339 throw((int)GetLastError());
340
341 BYTE dir_iv[DIR_IV_LEN];
342
343 if (reverse) {
344 if (!derive_path_iv(con, pt_path, dir_iv, TYPE_DIRIV)) {
345 throw((int)ERROR_PATH_NOT_FOUND);
346 }
347 } else {
348 if (!get_dir_iv(con, path, dir_iv)) {
349 DWORD error = GetLastError();
350 if (error == 0)
351 error = ERROR_PATH_NOT_FOUND;
352 throw((int)error);
353 }
354 }
355
356
357 bool isRoot = !wcscmp(pt_path, L"\\");
358
359 string actual_encrypted;
360
361 wstring storage;
362
363 storage.reserve(MAX_PATH);
364
365 do {
366 if (reverse && !wcscmp(fdata.cFileName, L".")) {
367 fdata_dot = fdata;
368 }

Callers 3

list_filesFunction · 0.85
load_dirMethod · 0.85

Calls 11

derive_path_ivFunction · 0.85
get_dir_ivFunction · 0.85
is_interesting_nameFunction · 0.85
convert_fdataFunction · 0.85
is_long_nameFunction · 0.85
VirtualAttributesDirIvFunction · 0.85
GetConfigMethod · 0.80
sizeMethod · 0.80
IsCaseInsensitiveMethod · 0.80
storeMethod · 0.45

Tested by

no test coverage detected