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

Function UriFromAbsolutePath

cpp/src/arrow/util/uri.cc:325–348  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

323}
324
325Result<std::string> UriFromAbsolutePath(std::string_view path) {
326 if (path.empty()) {
327 return Status::Invalid(
328 "UriFromAbsolutePath expected an absolute path, got an empty string");
329 }
330 std::string out;
331#ifdef _WIN32
332 // Turn "/" separators into "\", as Windows recognizes both but uriparser
333 // only the latter.
334 std::string fixed_path(path);
335 std::replace(fixed_path.begin(), fixed_path.end(), '/', '\\');
336 out.resize(8 + 3 * fixed_path.length() + 1);
337 int r = uriWindowsFilenameToUriStringA(fixed_path.data(), out.data());
338 // uriWindowsFilenameToUriStringA basically only fails if a null pointer is given.
339 ARROW_CHECK_EQ(r, 0) << "uriWindowsFilenameToUriStringA unexpectedly failed";
340#else
341 out.resize(7 + 3 * path.length() + 1);
342 int r = uriUnixFilenameToUriStringA(path.data(), out.data());
343 // same as above (uriWindowsFilenameToUriStringA)
344 ARROW_CHECK_EQ(r, 0) << "uriUnixFilenameToUriStringA unexpectedly failed";
345#endif
346 out.resize(strlen(out.data()));
347 return out;
348}
349
350} // namespace arrow::util

Callers 2

localfs_test.ccFile · 0.85
TESTFunction · 0.85

Calls 7

resizeMethod · 0.80
InvalidFunction · 0.50
emptyMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
lengthMethod · 0.45
dataMethod · 0.45

Tested by 1

TESTFunction · 0.68