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

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Zolotarev <deathbaba@gmail.com>2011-10-06 03:19:22 +0400
committerAlex Zolotarev <alex@maps.me>2015-09-23 01:25:19 +0300
commit176dd09294d330d238fb70896b9389920ae320e3 (patch)
tree0f0fa05452df67e896540c43719a9bd9abca7cbb /platform/platform_android.cpp
parent3081c5c45c7307c42cf5d1bce81495aea68eb1cb (diff)
[android] Fixed platform build issues
Diffstat (limited to 'platform/platform_android.cpp')
-rw-r--r--platform/platform_android.cpp103
1 files changed, 103 insertions, 0 deletions
diff --git a/platform/platform_android.cpp b/platform/platform_android.cpp
new file mode 100644
index 0000000000..4a9886eb07
--- /dev/null
+++ b/platform/platform_android.cpp
@@ -0,0 +1,103 @@
+#include "platform.hpp"
+
+#include "../coding/file_reader.hpp"
+#include "../coding/zip_reader.hpp"
+
+#include <dirent.h>
+#include <unistd.h>
+
+static string ReadPathForFile(string const & writableDir,
+ string const & resourcesDir, string const & file)
+{
+ string fullPath = writableDir + file;
+ if (!GetPlatform().IsFileExists(fullPath))
+ {
+ fullPath = resourcesDir + file;
+ if (!GetPlatform().IsFileExists(fullPath))
+ MYTHROW(FileAbsentException, ("File doesn't exist", fullPath));
+ }
+ return fullPath;
+}
+
+ModelReader * Platform::GetReader(string const & file) const
+{
+ if (IsFileExists(m_writableDir + file))
+ return new FileReader(ReadPathForFile(m_writableDir, m_resourcesDir, file), 10, 12);
+ else
+ { // paths from GetFilesInDir will already contain "assets/"
+ if (file.find("assets/") != string::npos)
+ return new ZipFileReader(m_resourcesDir, file);
+ else
+ return new ZipFileReader(m_resourcesDir, "assets/" + file);
+ }
+}
+
+void Platform::GetFilesInDir(string const & directory, string const & mask, FilesList & res) const
+{
+ if (ZipFileReader::IsZip(directory))
+ { // Get files list inside zip file
+ res = ZipFileReader::FilesList(directory);
+ // filter out according to the mask
+ // @TODO we don't support wildcards at the moment
+ string fixedMask = mask;
+ if (fixedMask.size() && fixedMask[0] == '*')
+ fixedMask.erase(0, 1);
+ for (FilesList::iterator it = res.begin(); it != res.end();)
+ {
+ if (it->find(fixedMask) == string::npos)
+ it = res.erase(it);
+ else
+ ++it;
+ }
+ }
+ else
+ {
+ DIR * dir;
+ struct dirent * entry;
+ if ((dir = opendir(directory.c_str())) == NULL)
+ return;
+ // TODO: take wildcards into account...
+ string mask_fixed = mask;
+ if (mask_fixed.size() && mask_fixed[0] == '*')
+ mask_fixed.erase(0, 1);
+ do
+ {
+ if ((entry = readdir(dir)) != NULL)
+ {
+ string fname(entry->d_name);
+ size_t index = fname.rfind(mask_fixed);
+ if (index != string::npos && index == fname.size() - mask_fixed.size())
+ {
+ res.push_back(fname);
+ }
+ }
+ } while (entry != NULL);
+
+ closedir(dir);
+ }
+}
+
+int Platform::CpuCores() const
+{
+ long const numCPU = sysconf(_SC_NPROCESSORS_ONLN);
+ if (numCPU >= 1)
+ return static_cast<int>(numCPU);
+ return 1;
+
+}
+
+string Platform::DeviceName() const
+{
+ return "Android";
+}
+
+double Platform::VisualScale() const
+{
+ return 1.3;
+}
+
+string Platform::SkinName() const
+{
+ return "basic.skn";
+}
+