예제 #1
0
extern const char* Settings_getInstallationDirectoryPath()
{
  const char *path = SettingsImpl__getInstallationDirectoryPath();
  if (path == NULL)
    MMC_THROW();
  return path;
}
예제 #2
0
// Do not free the returned variable. It's malloc'ed
char* SettingsImpl__getModelicaPath() {
  const char *path = getenv("OPENMODELICALIBRARY");
  int i = 0;
  if (path == NULL) {
    // By default, this is <omhome>/lib/omlibrary/
    const char *omhome = SettingsImpl__getInstallationDirectoryPath();
    if (omhome == NULL)
      return NULL;
    int lenOmhome = strlen(omhome);
    char *buffer = (char*) malloc(lenOmhome+100);
    snprintf(buffer,lenOmhome+100,"%s/lib/omlibrary",omhome);
    return buffer;
  }

#if defined(__MINGW32__) || defined(_MSC_VER)
  /* adrpo: translate this to forward slashes! */
  /* duplicate the path */
  winLibPath = strdup(path);

  /* ?? not enough memory for duplication */
  if (!winLibPath)
    return strdup(path);

  /* convert \\ to / */
  while(winLibPath[i] != '\0')
  {
    if (winLibPath[i] == '\\') winLibPath[i] = '/';
    i++;
  }
  /* set the termination */
  winLibPath[i] = '\0';
  return winLibPath;
#endif

  return strdup(path);
}