Welcome to mirror list, hosted at ThFree Co, Russian Federation.

platform_tizen.cpp « platform - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 62e542888d03f8f520b57f4b1d8fac87515712e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103

#include "platform.hpp"

#include <FAppApp.h>

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wignored-qualifiers"
  #include <FIo.h>
#pragma clang diagnostic pop

#include "constants.hpp"
#include "platform_unix_impl.hpp"

#include "../base/logging.hpp"
#include "../coding/file_reader.hpp"

#include <stdlib.h>
#include <unistd.h>

#include <sys/stat.h>
#include <sys/types.h>

#include "tizen_string_utils.hpp"

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()));
}

int Platform::CpuCores() const
{
  /// @todo
//  const long numCPU = sysconf(_SC_NPROCESSORS_ONLN);
//  if (numCPU >= 1)
//    return static_cast<int>(numCPU);
  return 1;
}

string Platform::UniqueClientId() const
{
  Tizen::App::App * pApp = Tizen::App::App::GetInstance();
  return FromTizenString(pApp->GetAppId());

}

void Platform::RunOnGuiThread(TFunctor const & fn)
{
  /// @todo
  fn();
}

void Platform::RunAsync(TFunctor const & fn, Priority p)
{
  /// @todo
  fn();
}

ModelReader * Platform::GetReader(string const & file, string const & searchScope) const
{
  return new FileReader(ReadPathForFile(file, searchScope),
                        READER_CHUNK_LOG_SIZE, READER_CHUNK_LOG_COUNT);
}

void Platform::GetFilesByRegExp(string const & directory, string const & regexp, FilesList & res)
{
  pl::EnumerateFilesByRegExp(directory, regexp, res);
}

bool Platform::GetFileSizeByName(string const & fileName, uint64_t & size) const
{
  try
  {
    return GetFileSizeByFullPath(ReadPathForFile(fileName, "wr"), size);
  }
  catch (RootException const &)
  {
    return false;
  }
}

////////////////////////////////////////////////////////////////////////
extern Platform & GetPlatform()
{
  static Platform platform;
  return platform;
}