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

Class CryptOpenHandles

libcppcryptfs/context/cryptcontext.h:47–78  ·  view source on GitHub ↗

This stores handles to open files so any left over after unmounting can be cleaned up

Source from the content-addressed store, hash-verified

45
46// This stores handles to open files so any left over after unmounting can be cleaned up
47class CryptOpenHandles {
48private:
49 unordered_set<HANDLE> m_handles;
50 mutex m_mutex;
51public:
52 // disallow copying
53 CryptOpenHandles(CryptOpenHandles const&) = delete;
54 void operator=(CryptOpenHandles const&) = delete;
55
56 CryptOpenHandles() {};
57
58 void insert(HANDLE h)
59 {
60 lock_guard<mutex> lck(m_mutex);
61 m_handles.insert(h);
62 }
63 void erase(HANDLE h)
64 {
65 lock_guard<mutex> lck(m_mutex);
66 m_handles.erase(h);
67 }
68 size_t size() {
69 lock_guard<mutex> lck(m_mutex);
70 return m_handles.size();
71 }
72 virtual ~CryptOpenHandles()
73 {
74 for (auto h : m_handles) {
75 ::CloseHandle(h);
76 }
77 }
78};
79
80// number of threads Dokany uses if threads is 0. Found from code inspection, not in header file
81#define CRYPT_DOKANY_DEFAULT_NUM_THREADS 5

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected