MCPcopy Create free account
hub / github.com/Meituan-Dianping/SQLAdvisor / init_default_directories

Function init_default_directories

mysys_ssl/my_default.cc:1363–1413  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1361
1362
1363static const char **init_default_directories(MEM_ROOT *alloc)
1364{
1365 const char **dirs;
1366 char *env;
1367 int errors= 0;
1368
1369 dirs= (const char **)alloc_root(alloc, DEFAULT_DIRS_SIZE * sizeof(char *));
1370 if (dirs == NULL)
1371 return NULL;
1372 memset(dirs, 0, DEFAULT_DIRS_SIZE * sizeof(char *));
1373
1374#ifdef __WIN__
1375
1376 {
1377 char fname_buffer[FN_REFLEN];
1378 if (my_get_system_windows_directory(fname_buffer, sizeof(fname_buffer)))
1379 errors += add_directory(alloc, fname_buffer, dirs);
1380
1381 if (GetWindowsDirectory(fname_buffer, sizeof(fname_buffer)))
1382 errors += add_directory(alloc, fname_buffer, dirs);
1383
1384 errors += add_directory(alloc, "C:/", dirs);
1385
1386 if (my_get_module_parent(fname_buffer, sizeof(fname_buffer)) != NULL)
1387 errors += add_directory(alloc, fname_buffer, dirs);
1388 }
1389
1390#else
1391
1392 errors += add_directory(alloc, "/etc/", dirs);
1393 errors += add_directory(alloc, "/etc/mysql/", dirs);
1394
1395#if defined(DEFAULT_SYSCONFDIR)
1396 if (DEFAULT_SYSCONFDIR[0])
1397 errors += add_directory(alloc, DEFAULT_SYSCONFDIR, dirs);
1398#endif /* DEFAULT_SYSCONFDIR */
1399
1400#endif
1401
1402 if ((env= getenv("MYSQL_HOME")))
1403 errors += add_directory(alloc, env, dirs);
1404
1405 /* Placeholder for --defaults-extra-file=<path> */
1406 errors += add_directory(alloc, "", dirs);
1407
1408#if !defined(__WIN__)
1409 errors += add_directory(alloc, "~/", dirs);
1410#endif
1411
1412 return (errors > 0 ? NULL : dirs);
1413}
1414
1415/**
1416 Place the login file name in the specified buffer.

Callers 2

my_load_defaultsFunction · 0.85
my_print_default_filesFunction · 0.85

Calls 4

alloc_rootFunction · 0.85
add_directoryFunction · 0.85
my_get_module_parentFunction · 0.85

Tested by

no test coverage detected