MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / translate

Method translate

src/common/config/config_file.cpp:509–559  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

507 */
508
509bool ConfigFile::translate(const char* fileName, const String& from, String& to) const
510{
511 if (from == "root")
512 {
513 to = Config::getRootDirectory();
514 }
515 else if (from == "install")
516 {
517 to = Config::getInstallDirectory();
518 }
519 else if (from == "this")
520 {
521 if (!fileName)
522 {
523 return false;
524 }
525
526 PathName tempPath(fileName);
527
528#ifdef UNIX
529 if (PathUtils::isSymLink(tempPath))
530 {
531 // If $(this) is a symlink, expand it.
532 TEXT temp[MAXPATHLEN];
533 const int n = readlink(fileName, temp, sizeof(temp));
534
535 if (n != -1)
536 {
537 tempPath.assign(temp, n);
538
539 if (PathUtils::isRelative(tempPath))
540 {
541 PathName parent;
542 PathUtils::splitLastComponent(parent, tempPath, fileName);
543 PathUtils::concatPath(tempPath, parent, temp);
544 }
545 }
546 }
547#endif
548
549 PathName path, file;
550 PathUtils::splitLastComponent(path, file, tempPath);
551 to = path.ToString();
552 }
553 else if (!substituteStandardDir(from, to))
554 {
555 return false;
556 }
557
558 return true;
559}
560
561/******************************************************************************
562 *

Callers

nothing calls this directly

Calls 3

readlinkFunction · 0.85
assignMethod · 0.45
ToStringMethod · 0.45

Tested by

no test coverage detected