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:
-rw-r--r--android/jni/com/mapswithme/maps/MWMActivity.cpp6
-rw-r--r--android/jni/com/mapswithme/platform/Platform.cpp6
-rw-r--r--android/jni/com/mapswithme/platform/Platform.hpp3
-rw-r--r--android/src/com/mapswithme/maps/MWMActivity.java17
-rw-r--r--platform/platform.hpp25
-rw-r--r--platform/platform_ios.mm3
-rw-r--r--platform/platform_linux.cpp10
-rw-r--r--platform/platform_mac.mm10
-rw-r--r--platform/platform_win.cpp7
-rw-r--r--platform/settings.cpp6
10 files changed, 80 insertions, 13 deletions
diff --git a/android/jni/com/mapswithme/maps/MWMActivity.cpp b/android/jni/com/mapswithme/maps/MWMActivity.cpp
index eb9c9ebe3d..4c8b3e5b21 100644
--- a/android/jni/com/mapswithme/maps/MWMActivity.cpp
+++ b/android/jni/com/mapswithme/maps/MWMActivity.cpp
@@ -36,11 +36,13 @@ extern "C"
}
JNIEXPORT void JNICALL
- Java_com_mapswithme_maps_MWMActivity_nativeInit(JNIEnv * env, jobject thiz, jstring apkPath, jstring storagePath)
+ Java_com_mapswithme_maps_MWMActivity_nativeInit(JNIEnv * env, jobject thiz,
+ jstring apkPath, jstring storagePath, jstring tmpPath, jstring settingsPath)
{
if (!g_framework)
{
- android::Platform::Instance().Initialize(env, apkPath, storagePath);
+ android::Platform::Instance().Initialize(env, apkPath, storagePath,
+ tmpPath, settingsPath);
g_framework = new android::Framework(g_jvm);
}
}
diff --git a/android/jni/com/mapswithme/platform/Platform.cpp b/android/jni/com/mapswithme/platform/Platform.cpp
index 4b79a3e622..193eb7f36b 100644
--- a/android/jni/com/mapswithme/platform/Platform.cpp
+++ b/android/jni/com/mapswithme/platform/Platform.cpp
@@ -6,10 +6,14 @@
namespace android
{
- void Platform::Initialize(JNIEnv * env, jstring apkPath, jstring storagePath)
+ void Platform::Initialize(JNIEnv * env, jstring apkPath, jstring storagePath,
+ jstring tmpPath, jstring settingsPath)
{
m_resourcesDir = jni::ToString(env, apkPath);
m_writableDir = jni::ToString(env, storagePath);
+ m_tmpDir = jni::ToString(env, tmpPath);
+ m_settingsDir = jni::ToString(env, settingsPath);
+
LOG(LDEBUG, ("Apk path = ", m_resourcesDir));
LOG(LDEBUG, ("Writable path = ", m_writableDir));
}
diff --git a/android/jni/com/mapswithme/platform/Platform.hpp b/android/jni/com/mapswithme/platform/Platform.hpp
index 9184ebf44a..3070fd0d7c 100644
--- a/android/jni/com/mapswithme/platform/Platform.hpp
+++ b/android/jni/com/mapswithme/platform/Platform.hpp
@@ -9,7 +9,8 @@ namespace android
class Platform : public ::Platform
{
public:
- void Initialize(JNIEnv * env, jstring apkPath, jstring storagePath);
+ void Initialize(JNIEnv * env, jstring apkPath, jstring storagePath,
+ jstring tmpPath, jstring settingsPath);
static Platform & Instance();
};
diff --git a/android/src/com/mapswithme/maps/MWMActivity.java b/android/src/com/mapswithme/maps/MWMActivity.java
index daec8d4354..86cb9df54a 100644
--- a/android/src/com/mapswithme/maps/MWMActivity.java
+++ b/android/src/com/mapswithme/maps/MWMActivity.java
@@ -53,11 +53,20 @@ public class MWMActivity extends NvEventQueueActivity implements
private String getDataStoragePath()
{
- String storagePath = Environment.getExternalStorageDirectory()
- .getAbsolutePath();
+ final String storagePath = Environment.getExternalStorageDirectory().getAbsolutePath();
return storagePath.concat(String.format("/Android/data/%s/files/", PACKAGE_NAME));
}
+ private String getTmpPath()
+ {
+ return getCacheDir().getAbsolutePath() + "/";
+ }
+
+ private String getSettingsPath()
+ {
+ return getFilesDir().getAbsolutePath() + "/";
+ }
+
private void checkMeasurementSystem()
{
int u;
@@ -157,7 +166,7 @@ public class MWMActivity extends NvEventQueueActivity implements
final File f = new File(storagePath);
f.mkdirs();
- nativeInit(getAppBundlePath(), storagePath);
+ nativeInit(getAppBundlePath(), storagePath, getTmpPath(), getSettingsPath());
setupLanguages();
@@ -352,7 +361,7 @@ public class MWMActivity extends NvEventQueueActivity implements
private native void nativeStorageConnected();
private native void nativeStorageDisconnected();
- private native void nativeInit(String apkPath, String storagePath);
+ private native void nativeInit(String apkPath, String storagePath, String tmpPath, String settingsPath);
private native void nativeLocationStatusChanged(int newStatus);
private native void nativeLocationUpdated(long time, double lat, double lon, float accuracy);
private native void nativeCompassUpdated(long time, double magneticNorth, double trueNorth, float accuracy);
diff --git a/platform/platform.hpp b/platform/platform.hpp
index a4c92a4dca..e73832d640 100644
--- a/platform/platform.hpp
+++ b/platform/platform.hpp
@@ -16,14 +16,24 @@ DECLARE_EXCEPTION(NotImplementedException, RootException);
class Platform
{
protected:
- string m_writableDir, m_resourcesDir;
+ /// Usually read-only directory for application resources
+ string m_resourcesDir;
+ /// Writable directory to store downloaded map data
+ /// @note on some systems it can point to external ejectable storage
+ string m_writableDir;
+ /// Temporary directory, can be cleaned up by the system
+ string m_tmpDir;
+ /// Writable directory to store persistent application data
+ string m_settingsDir;
+
class PlatformImpl;
/// Used only on those platforms where needed
PlatformImpl * m_impl;
static bool IsFileExistsByFullPath(string const & filePath);
- /// Internal function to use files from writable dir if they override the same in the resources
+ /// Internal function to use files from writable dir
+ /// if they override the same file in the resources dir
string ReadPathForFile(string const & file) const
{
string fullPath = m_writableDir + file;
@@ -48,6 +58,17 @@ public:
/// @return resource dir (on some platforms it's differ from Writable dir)
string ResourcesDir() const { return m_resourcesDir; }
+ /// @return path for directory with temporary files with slash at the end
+ string TmpDir() const { return m_tmpDir; }
+ /// @return full path to file in the temporary directory
+ string TmpPathForFile(string const & file) const { return TmpDir() + file; }
+
+ /// @return path for directory in the persistent memory, can be the same
+ /// as WritableDir, but on some platforms it's different
+ string SettingsDir() const { return m_settingsDir; }
+ /// @return full path to file in the settings directory
+ string SettingsPathForFile(string const & file) const { return SettingsDir() + file; }
+
/// @return reader for file decriptor.
/// @throws FileAbsentException
/// @param[in] file descriptor which we want to read
diff --git a/platform/platform_ios.mm b/platform/platform_ios.mm
index 404a055d53..cc03facf0b 100644
--- a/platform/platform_ios.mm
+++ b/platform/platform_ios.mm
@@ -50,6 +50,9 @@ Platform::Platform()
NSString * docsDir = [dirPaths objectAtIndex:0];
m_writableDir = [docsDir UTF8String];
m_writableDir += '/';
+ m_settingsDir = m_writableDir;
+ m_tmpDir = [NSHomeDirectory() UTF8String];
+ m_tmpDir += '/tmp/';
// Hardcoding screen resolution depending on the device we are running.
m_impl->m_visualScale = 1.0;
diff --git a/platform/platform_linux.cpp b/platform/platform_linux.cpp
index 9cfebaa4b5..634caf3f17 100644
--- a/platform/platform_linux.cpp
+++ b/platform/platform_linux.cpp
@@ -41,9 +41,17 @@ Platform::Platform()
// @TODO implement correct resources and writable directories for public releases
m_resourcesDir = path + "../../data/";
m_writableDir = m_resourcesDir;
+ m_settingsDir = m_writableDir;
+ char * tmpDir = ::getenv("TMPDIR");
+ if (tmpDir)
+ m_tmpDir = tmpDir;
+ else
+ m_tmpDir = P_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));
}
Platform::~Platform()
@@ -58,7 +66,7 @@ bool Platform::IsFileExistsByFullPath(string const & filePath)
int Platform::CpuCores() const
{
- long numCPU = sysconf(_SC_NPROCESSORS_ONLN);
+ const long numCPU = sysconf(_SC_NPROCESSORS_ONLN);
if (numCPU >= 1)
return static_cast<int>(numCPU);
return 1;
diff --git a/platform/platform_mac.mm b/platform/platform_mac.mm
index 7db07c03e8..73e4bb1137 100644
--- a/platform/platform_mac.mm
+++ b/platform/platform_mac.mm
@@ -54,8 +54,18 @@ Platform::Platform()
}
[pool release];
+ m_settingsDir = m_writableDir;
+
+ NSString * tempDir = NSTemporaryDirectory();
+ if (tempDir == nil)
+ tempDir = @"/tmp";
+ m_tmpDir = [tempDir UTF8String];
+ 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));
}
Platform::~Platform()
diff --git a/platform/platform_win.cpp b/platform/platform_win.cpp
index 62934716b2..4edfe71d71 100644
--- a/platform/platform_win.cpp
+++ b/platform/platform_win.cpp
@@ -73,8 +73,15 @@ Platform::Platform()
}
FileWriter::DeleteFileX(m_resourcesDir + "mapswithmetmptestfile");
+ m_settingsDir = m_writableDir;
+ char pathBuf[MAX_PATH] = {0};
+ GetTempPathA(MAX_PATH, pathBuf);
+ m_tmpDir = pathBuf;
+
LOG(LDEBUG, ("Resources Directory:", m_resourcesDir));
LOG(LDEBUG, ("Writable Directory:", m_writableDir));
+ LOG(LDEBUG, ("Tmp Directory:", m_tmpDir));
+ LOG(LDEBUG, ("Settings Directory:", m_settingsDir));
}
Platform::~Platform()
diff --git a/platform/settings.cpp b/platform/settings.cpp
index 67bbf18753..d70b3273a8 100644
--- a/platform/settings.cpp
+++ b/platform/settings.cpp
@@ -23,7 +23,9 @@ namespace Settings
try
{
string str;
- ReaderPtr<Reader>(GetPlatform().GetReader(SETTINGS_FILE_NAME)).ReadAsString(str);
+ {
+ FileReader(GetPlatform().SettingsPathForFile(SETTINGS_FILE_NAME)).ReadAsString(str);
+ }
istringstream stream(str);
string line;
while (stream.good())
@@ -53,7 +55,7 @@ namespace Settings
// @TODO add mutex
try
{
- FileWriter file(GetPlatform().WritablePathForFile(SETTINGS_FILE_NAME));
+ FileWriter file(GetPlatform().SettingsPathForFile(SETTINGS_FILE_NAME));
for (ContainerT::const_iterator it = m_values.begin(); it != m_values.end(); ++it)
{
string line(it->first);