summaryrefslogtreecommitdiffstats
path: root/WebKit/android/jni/WebIconDatabase.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'WebKit/android/jni/WebIconDatabase.cpp')
-rw-r--r--WebKit/android/jni/WebIconDatabase.cpp26
1 files changed, 22 insertions, 4 deletions
diff --git a/WebKit/android/jni/WebIconDatabase.cpp b/WebKit/android/jni/WebIconDatabase.cpp
index a9f6b05..2a660d1 100644
--- a/WebKit/android/jni/WebIconDatabase.cpp
+++ b/WebKit/android/jni/WebIconDatabase.cpp
@@ -28,6 +28,7 @@
#include "config.h"
#include "WebIconDatabase.h"
+#include "FileSystem.h"
#include "GraphicsJNI.h"
#include "IconDatabase.h"
#include "Image.h"
@@ -140,10 +141,27 @@ static void Open(JNIEnv* env, jobject obj, jstring path)
iconDb->setClient(gIconDatabaseClient);
LOG_ASSERT(path, "No path given to nativeOpen");
WTF::String pathStr = jstringToWtfString(env, path);
- LOGV("Opening WebIconDatabase file '%s'", pathStr.latin1().data());
- bool res = iconDb->open(pathStr);
- if (!res)
- LOGE("Open failed!");
+ WTF::CString fullPath = WebCore::pathByAppendingComponent(pathStr,
+ WebCore::IconDatabase::defaultDatabaseFilename()).utf8();
+ mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP;
+ bool didSetPermissions = false;
+ if (access(fullPath.data(), F_OK) == 0) {
+ if (chmod(fullPath.data(), mode) == 0)
+ didSetPermissions = true;
+ } else {
+ int fd = open(fullPath.data(), O_CREAT, mode);
+ if (fd >= 0) {
+ close(fd);
+ didSetPermissions = true;
+ }
+ }
+ if (didSetPermissions) {
+ LOGV("Opening WebIconDatabase file '%s'", pathStr.latin1().data());
+ bool res = iconDb->open(pathStr);
+ if (!res)
+ LOGE("Open failed!");
+ } else
+ LOGE("Failed to set permissions on '%s'", fullPath.data());
}
static void Close(JNIEnv* env, jobject obj)