in src/main/cpp/ide/nblauncher.cpp [463:509]
bool NbLauncher::parseConfigFile(const char* path) {
logMsg("parseConfigFile(%s)", path);
FILE *file = fopen(path, "r");
if (!file) {
logErr(true, false, "Cannot open file \"%s\" for reading.", path);
return false;
}
char line[4096] = "";
while (fgets(line, sizeof(line), file)) {
char *str = skipWhitespaces(line);
if (*str == '#') {
continue;
}
if (getOption(str, getDefUserDirOptName())) {
findUserDir(str);
logMsg("User dir: %s", userDir.c_str());
} else if (getOption(str, getDefCacheDirOptName())) {
findCacheDir(str);
logMsg("Cache dir: %s", cacheDir.c_str());
} else if (getOption(str, getDefOptionsOptName())) {
// replace \" by "
int len = strlen(str);
int k = 0;
for (int i = 0; i < len; i++) {
if (str[i] == '\\' && str[i+1] == '\"') {
continue;
}
str[k++] = str[i];
}
str[k] = '\0';
nbOptions = str;
logMsg("After replacement: %s", nbOptions.c_str());
} else if (getOption(str, getExtraClustersOptName())) {
extraClusters = str;
} else if (getOption(str, getJdkHomeOptName())) {
jdkHome = str;
}
}
bool ok = ferror(file) == 0;
if (!ok) {
logErr(true, false, "Error while reading file \"%s\".", path);
}
fclose(file);
return true;
}