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

Function CheckOpenHandles

cppcryptfs/ui/uiutil.cpp:103–139  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

101}
102
103wstring CheckOpenHandles(HWND hWnd, const wchar_t* mp, bool interactive, bool force)
104{
105
106 if (force)
107 return L"";
108
109 bool warn = false;
110 CryptSettings::getInstance().GetSettingCurrent(WARN_IF_IN_USE_ON_DISMOUNT, warn);
111
112 if (!warn) {
113 return L"";
114 }
115
116 int open_handle_count = get_open_handle_count(mp);
117
118 if (open_handle_count < 0) {
119 return L"Unable to determine if any handles are open";
120 }
121 else if (open_handle_count > 0) {
122 if (interactive) {
123 CString strMsg;
124 strMsg.Format(LocUtils::GetStringFromResources(IDS_IS_STILL_IN_USE).c_str(), mp);
125 auto res = ::MessageBox(hWnd, mp ? strMsg : LocUtils::GetStringFromResources(IDS_FS_IS_STILL_IN_USE).c_str(), L"cppcryptfs", MB_YESNO | MB_ICONHAND);
126 if (res == IDYES)
127 return L"";
128 else {
129 std::wstring strMsgCanceledByUser = LocUtils::GetStringFromResources(IDS_CANCELED_BY_USER);
130 return strMsgCanceledByUser;
131 }
132 }
133 else {
134 return mp ? wstring(mp) + L" is still in use. Use --force to force dismounting." :
135 L"Filesystem(s) are still in use. Use --force to force dismounting.";
136 }
137 }
138 return L"";
139}

Callers 3

CanCloseMethod · 0.85
DismountMethod · 0.85
DismountAllMethod · 0.85

Calls 2

get_open_handle_countFunction · 0.85
GetSettingCurrentMethod · 0.80

Tested by

no test coverage detected