MCPcopy Create free account
hub / github.com/Kitware/VTK / pj_open_lib_internal

Function pj_open_lib_internal

ThirdParty/libproj/vtklibproj/src/filemanager.cpp:1409–1566  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1407}
1408
1409static void *pj_open_lib_internal(
1410 PJ_CONTEXT *ctx, const char *name, const char *mode,
1411 void *(*open_file)(PJ_CONTEXT *, const char *, const char *),
1412 char *out_full_filename, size_t out_full_filename_size) {
1413 try {
1414 std::string fname;
1415 const char *sysname = nullptr;
1416 void *fid = nullptr;
1417 std::string projLib;
1418
1419 if (ctx == nullptr) {
1420 ctx = pj_get_default_ctx();
1421 }
1422
1423 if (out_full_filename != nullptr && out_full_filename_size > 0)
1424 out_full_filename[0] = '\0';
1425
1426 /* check if ~/name */
1427 if (is_tilde_slash(name))
1428 if ((sysname = getenv("HOME")) != nullptr) {
1429 fname = sysname;
1430 fname += DIR_CHAR;
1431 fname += name;
1432 sysname = fname.c_str();
1433 } else
1434 return nullptr;
1435
1436 /* or fixed path: /name, ./name or ../name */
1437 else if (is_rel_or_absolute_filename(name)) {
1438 sysname = name;
1439#ifdef _WIN32
1440 try {
1441 NS_PROJ::UTF8ToWString(name);
1442 } catch (const std::exception &) {
1443 fname = NS_PROJ::Win32Recode(name, CP_ACP, CP_UTF8);
1444 sysname = fname.c_str();
1445 }
1446#endif
1447 }
1448
1449 else if (starts_with(name, "http://") || starts_with(name, "https://"))
1450 sysname = name;
1451
1452 /* or try to use application provided file finder */
1453 else if (ctx->file_finder != nullptr &&
1454 (sysname = ctx->file_finder(
1455 ctx, name, ctx->file_finder_user_data)) != nullptr)
1456 ;
1457
1458 /* The user has search paths set */
1459 else if (!ctx->search_paths.empty()) {
1460 for (const auto &path : ctx->search_paths) {
1461 try {
1462 fname = path;
1463 fname += DIR_CHAR;
1464 fname += name;
1465 sysname = fname.c_str();
1466 fid = open_file(ctx, sysname, mode);

Callers 3

open_resource_fileMethod · 0.85
pj_find_fileFunction · 0.85
pj_load_iniFunction · 0.85

Calls 15

pj_get_default_ctxFunction · 0.85
UTF8ToWStringFunction · 0.85
Win32RecodeFunction · 0.85
proj_context_errno_setFunction · 0.85
pj_logFunction · 0.85
is_tilde_slashFunction · 0.70
starts_withFunction · 0.50
open_fileFunction · 0.50
stringClass · 0.50

Tested by

no test coverage detected