This stores handles to open files so any left over after unmounting can be cleaned up
| 45 | |
| 46 | // This stores handles to open files so any left over after unmounting can be cleaned up |
| 47 | class CryptOpenHandles { |
| 48 | private: |
| 49 | unordered_set<HANDLE> m_handles; |
| 50 | mutex m_mutex; |
| 51 | public: |
| 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 |
nothing calls this directly
no outgoing calls
no test coverage detected