Exemple #1
0
Platform::Platform()
{
  Tizen::App::App * pApp = Tizen::App::App::GetInstance();
  // init directories
  string app_root = FromTizenString(pApp->GetAppRootPath());

  m_writableDir = FromTizenString(pApp->GetAppDataPath());
  m_resourcesDir = FromTizenString(pApp->GetAppResourcePath());
  m_settingsDir = m_writableDir + "settings/";
  Tizen::Io::Directory::Create(m_settingsDir.c_str(), true);

  m_tmpDir = m_writableDir + "tmp/";
  Tizen::Io::Directory::Create(m_tmpDir.c_str(), true);

  LOG(LDEBUG, ("App directory:", app_root));
  LOG(LDEBUG, ("Resources directory:", m_resourcesDir));
  LOG(LDEBUG, ("Writable directory:", m_writableDir));
  LOG(LDEBUG, ("Tmp directory:", m_tmpDir));
  LOG(LDEBUG, ("Settings directory:", m_settingsDir));
  LOG(LDEBUG, ("Client ID:", UniqueClientId()));

  m_flags[HAS_BOOKMARKS] = true;
  m_flags[HAS_ROTATION] = true;
  m_flags[HAS_ROUTING] = true;
}
Exemple #2
0
Platform::Platform()
{
  // Init directories.
  string path;
  CHECK(GetBinaryDir(path), ("Can't retrieve path to executable"));

  char const * homePath = ::getenv("HOME");
  string const home(homePath ? homePath : "");

  m_settingsDir = my::JoinFoldersToPath({home, ".config"}, "MapsWithMe");

  if (!IsFileExistsByFullPath(my::JoinFoldersToPath(m_settingsDir, SETTINGS_FILE_NAME)))
  {
    MkDir(my::JoinFoldersToPath(home, ".config"));
    MkDir(m_settingsDir.c_str());
  }

  m_writableDir = my::JoinFoldersToPath({home, ".local", "share"}, "MapsWithMe");
  MkDir(my::JoinFoldersToPath(home, ".local"));
  MkDir(my::JoinFoldersToPath({home, ".local"}, "share"));
  MkDir(m_writableDir);

  char const * resDir = ::getenv("MWM_RESOURCES_DIR");
  if (resDir)
  {
    m_resourcesDir = resDir;
  }
  else
  {
    string const devBuildWithSymlink = my::JoinFoldersToPath({path, "..", ".."}, "data");
    string const devBuildWithoutSymlink =
        my::JoinFoldersToPath({path, "..", "..", "..", "omim"}, "data");
    string const installedVersionWithPackages = my::JoinFoldersToPath({path, ".."}, "share");
    string const installedVersionWithoutPackages =
        my::JoinFoldersToPath({path, ".."}, "MapsWithMe");
    string const customInstall = path;

    if (IsEulaExist(devBuildWithSymlink))
    {
      m_resourcesDir = devBuildWithSymlink;
      m_writableDir = m_resourcesDir;
    }
    else if (IsEulaExist(devBuildWithoutSymlink))
    {
      m_resourcesDir = devBuildWithoutSymlink;
      m_writableDir = m_resourcesDir;
    }
    else if (IsEulaExist(installedVersionWithPackages))
    {
      m_resourcesDir = installedVersionWithPackages;
    }
    else if (IsEulaExist(installedVersionWithoutPackages))
    {
      m_resourcesDir = installedVersionWithoutPackages;
    }
    else if (IsEulaExist(customInstall))
    {
      m_resourcesDir = path;
    }
  }
  m_resourcesDir += '/';
  m_settingsDir += '/';
  m_writableDir += '/';

  char const * tmpDir = ::getenv("TMPDIR");
  if (tmpDir)
    m_tmpDir = tmpDir;
  else
    m_tmpDir = "/tmp";
  m_tmpDir += '/';

  LOG(LDEBUG, ("Resources directory:", m_resourcesDir));
  LOG(LDEBUG, ("Writable directory:", m_writableDir));
  LOG(LDEBUG, ("Tmp directory:", m_tmpDir));
  LOG(LDEBUG, ("Settings directory:", m_settingsDir));
  LOG(LDEBUG, ("Client ID:", UniqueClientId()));
}