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

Function GetEnvVarNative

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

Source from the content-addressed store, hash-verified

1792
1793#ifdef _WIN32
1794Result<NativePathString> GetEnvVarNative(std::string_view name) {
1795 ARROW_ASSIGN_OR_RAISE(std::wstring w_name, StringToNative(name));
1796 std::wstring value(100, '\0');
1797
1798 uint32_t res = GetEnvironmentVariableW(w_name.data(), value.data(),
1799 static_cast<uint32_t>(value.size()));
1800 if (res >= value.size()) {
1801 // Value buffer too small, need to upsize
1802 // (`res` includes the null-terminating character in this case)
1803 value.resize(res);
1804 res = GetEnvironmentVariableW(w_name.data(), value.data(),
1805 static_cast<uint32_t>(value.size()));
1806 }
1807 if (res == 0) {
1808 return Status::KeyError("environment variable '", name, "' undefined");
1809 }
1810 // On success, `res` does not include the null-terminating character
1811 DCHECK_EQ(value.data()[res], 0);
1812 value.resize(res);
1813 return value;
1814}
1815
1816#else
1817

Callers 3

AppendEnvVarFilenameFunction · 0.85
InsertEnvVarFilenameFunction · 0.85
GetPlatformTemporaryDirsFunction · 0.85

Calls 5

KeyErrorFunction · 0.85
GetEnvVarFunction · 0.85
resizeMethod · 0.80
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected