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

Method store

libcppcryptfs/filename/casecache.cpp:155–235  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

153}
154
155bool CaseCache::store(LPCWSTR dirpath, const list<wstring>& files)
156{
157 bool bRet = true;
158
159 wstring key;
160
161 if (!touppercase(dirpath, key))
162 return false;
163
164 lock();
165
166 try {
167 // see if it's already there
168 auto mp = m_map.emplace(key, (CaseCacheNode*)NULL);
169
170 if (mp.second) {
171
172 CaseCacheNode *node = NULL;
173
174 // if it isn't, then see if the cache is full
175
176 // if so, remove oldest entry (from tail of linked list)
177
178 if (m_map.size() > CASE_CACHE_ENTRIES) {
179 node = m_lru_list.back();
180 m_lru_list.pop_back();
181 m_map.erase(node->m_key);
182 node->m_files.clear();
183 }
184
185 // re-use node if we removed one, otherwise get one from spare list, otherwise make a new one
186
187 if (!node) {
188 if (!m_spare_node_list.empty()) {
189 node = m_spare_node_list.front();
190 m_spare_node_list.pop_front();
191 } else {
192 node = new CaseCacheNode;
193 }
194 }
195
196 mp.first->second = node;
197
198 node->m_key = mp.first->first;
199 node->m_path = dirpath;
200 wstring ucfile;
201 for (auto it = files.begin(); it != files.end(); ++it) {
202 if (!touppercase(it->c_str(), ucfile)) {
203 throw(-1);
204 }
205 node->m_files.insert(make_pair(ucfile, *it));
206 }
207 node->m_timestamp = GetTickCount64();
208 GetSystemTimeAsFileTime(&node->m_filetime);
209 m_lru_list.push_front(node);
210 node->m_list_it = m_lru_list.begin();
211
212 } else {

Callers 5

CryptMoveFileInternalFunction · 0.45
get_dir_ivFunction · 0.45
find_filesFunction · 0.45
create_dir_ivFunction · 0.45

Calls 8

touppercaseFunction · 0.85
get_file_streamFunction · 0.85
sizeMethod · 0.80
eraseMethod · 0.80
emptyMethod · 0.80
insertMethod · 0.80
findMethod · 0.80

Tested by

no test coverage detected