| 4107 | { |
| 4108 | public: |
| 4109 | static void init() |
| 4110 | { |
| 4111 | // Get fb_prefix value from config file |
| 4112 | // CVC: I put this protection block because we can't raise exceptions |
| 4113 | // if exceptions are already raised due to the same reason: |
| 4114 | // config file not found. |
| 4115 | Firebird::PathName prefix; |
| 4116 | try |
| 4117 | { |
| 4118 | prefix = Firebird::Config::getRootDirectory(); |
| 4119 | if (prefix.isEmpty() && !GetProgramFilesDir(prefix)) |
| 4120 | prefix = FB_CONFDIR[0] ? FB_CONFDIR : FB_PREFIX; |
| 4121 | } |
| 4122 | catch (const Firebird::Exception&) |
| 4123 | { |
| 4124 | // CVC: Presumably here we failed because the config file can't be located. |
| 4125 | if (!GetProgramFilesDir(prefix)) |
| 4126 | prefix = FB_CONFDIR[0] ? FB_CONFDIR : FB_PREFIX; |
| 4127 | } |
| 4128 | prefix.copyTo(fb_prefix_val, sizeof(fb_prefix_val)); |
| 4129 | fb_prefix = fb_prefix_val; |
| 4130 | |
| 4131 | // Find appropiate temp directory |
| 4132 | Firebird::PathName tempDir; |
| 4133 | if (!fb_utils::readenv(FB_TMP_ENV, tempDir)) |
| 4134 | { |
| 4135 | #ifdef WIN_NT |
| 4136 | const DWORD len = GetTempPath(sizeof(fbTempDir), fbTempDir); |
| 4137 | // This checks "TEMP" and "TMP" environment variables |
| 4138 | if (len && len < sizeof(fbTempDir)) |
| 4139 | { |
| 4140 | tempDir = fbTempDir; |
| 4141 | } |
| 4142 | #else |
| 4143 | fb_utils::readenv("TMP", tempDir); |
| 4144 | #endif |
| 4145 | } |
| 4146 | if (!tempDir.length() || tempDir.length() >= MAXPATHLEN) |
| 4147 | { |
| 4148 | const char* tmp = getTemporaryFolder(); |
| 4149 | if (tmp) |
| 4150 | tempDir = tmp; |
| 4151 | else |
| 4152 | tempDir = WORKFILE; |
| 4153 | } |
| 4154 | tempDir.copyTo(fbTempDir, sizeof(fbTempDir)); |
| 4155 | |
| 4156 | // Find appropriate Firebird lock file prefix |
| 4157 | // Override conditional defines with the enviroment |
| 4158 | // variable FIREBIRD_LOCK if it is set. |
| 4159 | Firebird::PathName lockPrefix; |
| 4160 | if (!fb_utils::readenv(FB_LOCK_ENV, lockPrefix)) |
| 4161 | { |
| 4162 | #if !defined(WIN_NT) |
| 4163 | const char* tmp = getTemporaryFolder(); |
| 4164 | if (!tmp) |
| 4165 | tmp = WORKFILE; |
| 4166 | PathUtils::concatPath(lockPrefix, tmp, LOCKDIR); |
no test coverage detected