MCPcopy Create free account
hub / github.com/apache/arrow / FileExists

Function FileExists

cpp/src/arrow/util/io_util.cc:982–1006  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

980}
981
982Result<bool> FileExists(const PlatformFilename& path) {
983#ifdef _WIN32
984 if (GetFileAttributesW(path.ToNative().c_str()) != INVALID_FILE_ATTRIBUTES) {
985 return true;
986 } else {
987 int errnum = GetLastError();
988 if (errnum != ERROR_PATH_NOT_FOUND && errnum != ERROR_FILE_NOT_FOUND) {
989 return IOErrorFromWinError(GetLastError(), "Failed getting information for path '",
990 path.ToString(), "'");
991 }
992 return false;
993 }
994#else
995 struct stat st;
996 if (stat(path.ToNative().c_str(), &st) == 0) {
997 return true;
998 } else {
999 if (errno != ENOENT && errno != ENOTDIR) {
1000 return IOErrorFromErrno(errno, "Failed getting information for path '",
1001 path.ToString(), "'");
1002 }
1003 return false;
1004 }
1005#endif
1006}
1007
1008//
1009// Creating and destroying file descriptors

Callers 3

AssertExistsFunction · 0.70
AssertNotExistsFunction · 0.70
public_api_test.ccFile · 0.50

Calls 4

IOErrorFromWinErrorFunction · 0.85
IOErrorFromErrnoFunction · 0.85
statClass · 0.70
ToStringMethod · 0.45

Tested by 2

AssertExistsFunction · 0.56
AssertNotExistsFunction · 0.56