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

Method rename

libcppcryptfs/filename/casecache.cpp:525–594  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

523// when a directory is renamed, do a search and replace in the cache
524
525bool CaseCache::rename(LPCWSTR oldpath, LPCWSTR newpath)
526{
527 bool bRet = true;
528
529 wstring ucold;
530
531 if (!touppercase(oldpath, ucold))
532 return false;
533
534 wstring ucnew;
535
536 if (!touppercase(newpath, ucnew))
537 return false;
538
539 size_t oldlen = ucold.length();
540
541 size_t newlen = ucnew.length();
542
543 wstring newkey;
544
545 list<wstring> toerase;
546
547 list<pair<wstring, CaseCacheNode *>> toinsert;
548
549 lock();
550
551 try {
552
553 for (auto it : m_map) {
554 size_t keylen = it.first.length();
555
556 if (keylen < oldlen)
557 continue;
558
559 if (wcsncmp(ucold.c_str(), it.first.c_str(), oldlen))
560 continue;
561
562 newkey = ucnew + it.first.substr(oldlen);
563
564 it.second->m_path = newpath + it.second->m_path.substr(oldlen);
565
566 it.second->m_key = newkey;
567
568 toerase.push_back(it.first);
569
570 toinsert.push_back(make_pair(newkey, it.second));
571 }
572
573 for (auto it : toerase) {
574 m_map.erase(it);
575 }
576
577 for (auto it : toinsert) {
578 auto pr = m_map.insert(it);
579 if (!pr.second) {
580 // wasn't really inserted
581 m_lru_list.erase(it.second->m_list_it);
582 it.second->m_files.clear();

Callers 1

CryptMoveFileInternalFunction · 0.80

Calls 3

touppercaseFunction · 0.85
eraseMethod · 0.80
insertMethod · 0.80

Tested by

no test coverage detected