diff options
author | vng <viktor.govako@gmail.com> | 2012-06-30 07:44:09 +0400 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 01:40:26 +0300 |
commit | 89d69320571811fc36adf84ea9a11a5df704ee9c (patch) | |
tree | 999ae04dd60e4471411d50f0597ce00be2e4459e /platform/platform_android.cpp | |
parent | 1a7cff91e18008084fb72c5348457578cb550bae (diff) |
Factor out common Platform implementations for Unix-based OS.
Diffstat (limited to 'platform/platform_android.cpp')
-rw-r--r-- | platform/platform_android.cpp | 72 |
1 files changed, 3 insertions, 69 deletions
diff --git a/platform/platform_android.cpp b/platform/platform_android.cpp index 8046a07e5e..d905d53e37 100644 --- a/platform/platform_android.cpp +++ b/platform/platform_android.cpp @@ -1,4 +1,5 @@ #include "platform.hpp" +#include "platform_unix_impl.hpp" #include "constants.hpp" #include "../coding/zip_reader.hpp" @@ -6,9 +7,7 @@ #include "../base/logging.hpp" #include "../base/thread.hpp" -#include <dirent.h> #include <unistd.h> -#include <sys/stat.h> Platform::Platform() : m_impl(0) @@ -17,13 +16,6 @@ Platform::Platform() : m_impl(0) Platform::~Platform() {} -/// @warning doesn't work for files inside .apk (zip)!!! -bool Platform::IsFileExistsByFullPath(string const & filePath) -{ - struct stat s; - return stat(filePath.c_str(), &s) == 0; -} - ModelReader * Platform::GetReader(string const & file) const { if (IsFileExistsByFullPath(m_writableDir + file)) @@ -41,19 +33,6 @@ ModelReader * Platform::GetReader(string const & file) const } } -namespace -{ - string GetFixedMask(string const & mask) - { - // Filter out according to the mask. - // @TODO we don't support wildcards at the moment - if (!mask.empty() && mask[0] == '*') - return string(mask.c_str() + 1); - else - return mask; - } -} - void Platform::GetFilesInDir(string const & directory, string const & mask, FilesList & res) { if (ZipFileReader::IsZip(directory)) @@ -62,7 +41,7 @@ void Platform::GetFilesInDir(string const & directory, string const & mask, File FilesList fList; ZipFileReader::FilesList(directory, fList); - string const fixedMask = GetFixedMask(mask); + string const fixedMask = pl::GetFixedMask(mask); for (FilesList::iterator it = fList.begin(); it != fList.end(); ++it) { @@ -78,24 +57,7 @@ void Platform::GetFilesInDir(string const & directory, string const & mask, File } } else - { - DIR * dir; - struct dirent * entry; - if ((dir = opendir(directory.c_str())) == NULL) - return; - - string const fixedMask = GetFixedMask(mask); - - while ((entry = readdir(dir)) != 0) - { - string const fname(entry->d_name); - size_t const index = fname.rfind(fixedMask); - if ((index != string::npos) && (index == fname.size() - fixedMask.size())) - res.push_back(fname); - } - - closedir(dir); - } + pl::EnumerateFilesInDir(directory, mask, res); } int Platform::CpuCores() const @@ -118,22 +80,6 @@ string Platform::DeviceName() const return "Android"; } -void Platform::GetFontNames(FilesList & res) const -{ - string arr[] = { WritableDir(), ResourcesDir() }; - - for (size_t i = 0; i < ARRAY_SIZE(arr); ++i) - { - LOG(LDEBUG, ("Searching for fonts in", arr[i])); - GetFilesInDir(arr[i], "*.ttf", res); - } - - sort(res.begin(), res.end()); - res.erase(unique(res.begin(), res.end()), res.end()); - - LOG(LDEBUG, ("Font files:", (res))); -} - int Platform::ScaleEtalonSize() const { return 512 + 256; @@ -157,18 +103,6 @@ bool Platform::GetFileSizeByName(string const & fileName, uint64_t & size) const } } -/// @warning doesn't work for files inside .apk (zip)!!! -bool Platform::GetFileSizeByFullPath(string const & filePath, uint64_t & size) -{ - struct stat s; - if (stat(filePath.c_str(), &s) == 0) - { - size = s.st_size; - return true; - } - return false; -} - void Platform::RunOnGuiThread(TFunctor const & fn) { /// @todo |