MCPcopy Create free account
hub / github.com/CppMicroServices/CppMicroServices / Exists

Function Exists

util/src/FileSystem.cpp:216–249  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

214 }
215
216 bool
217 Exists(std::string const& path)
218 {
219#ifdef US_PLATFORM_POSIX
220 US_STAT s;
221 errno = 0;
222 if (us_stat(path.c_str(), &s))
223 {
224 if (not_found_c_error(errno))
225 {
226 return false;
227 }
228 else
229 {
230 throw std::invalid_argument(GetLastCErrorStr());
231 }
232 }
233#else
234 std::wstring wpath(ToWString(path));
235 DWORD attr(::GetFileAttributesW(wpath.c_str()));
236 if (attr == INVALID_FILE_ATTRIBUTES)
237 {
238 if (not_found_win32_error(::GetLastError()))
239 {
240 return false;
241 }
242 else
243 {
244 throw std::invalid_argument(GetLastWin32ErrorStr());
245 }
246 }
247#endif
248 return true;
249 }
250
251 bool
252 IsDirectory(std::string const& path)

Callers 7

TESTFunction · 0.85
TESTFunction · 0.85
TEST_FFunction · 0.85
GetDataFileMethod · 0.85
UninstallMethod · 0.85
GetPersistentStoragePathFunction · 0.85

Calls 5

not_found_c_errorFunction · 0.85
GetLastCErrorStrFunction · 0.85
ToWStringFunction · 0.85
not_found_win32_errorFunction · 0.85
GetLastWin32ErrorStrFunction · 0.85

Tested by 3

TESTFunction · 0.68
TESTFunction · 0.68
TEST_FFunction · 0.68