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

Class CryptOpenFile

libcppcryptfs/file/openfiles.h:71–137  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

69};
70
71class CryptOpenFile {
72private:
73 CryptFileMutex m_mutex;
74 unordered_map<HANDLE, DWORD> m_handles;
75public:
76 CryptOpenFile() = delete;
77 virtual ~CryptOpenFile() = default;
78
79 CryptOpenFile(HANDLE h)
80 {
81 m_handles[h] = 1;
82 }
83
84 void Open(HANDLE h)
85 {
86 auto it = m_handles.find(h);
87 if (it == m_handles.end()) {
88 m_handles[h] = 1;
89 } else {
90 it->second++;
91 }
92 }
93
94 bool Close(HANDLE h)
95 {
96 auto it = m_handles.find(h);
97 if (it == m_handles.end()) {
98 return false;
99 }
100
101 it->second--;
102
103 if (it->second == 0)
104 m_handles.erase(h);
105
106 return true;
107 }
108
109 bool Empty()
110 {
111 return m_handles.empty();
112 }
113
114 void LockShared()
115 {
116 m_mutex.lock_shared();
117 }
118
119 void UnlockShared()
120 {
121 m_mutex.unlock_shared();
122 }
123
124 void LockExclusive()
125 {
126 m_mutex.lock();
127 }
128

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected