summaryrefslogtreecommitdiffstats
path: root/WebCore/platform/android/FileSystemAndroid.cpp
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2008-12-17 18:05:15 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2008-12-17 18:05:15 -0800
commit1cbdecfa9fc428ac2d8aca0fa91c9580b3d57353 (patch)
tree4457a7306ea5acb43fe05bfe0973b1f7faf97ba2 /WebCore/platform/android/FileSystemAndroid.cpp
parent9364f22aed35e1a1e9d07c121510f80be3ab0502 (diff)
downloadexternal_webkit-1cbdecfa9fc428ac2d8aca0fa91c9580b3d57353.zip
external_webkit-1cbdecfa9fc428ac2d8aca0fa91c9580b3d57353.tar.gz
external_webkit-1cbdecfa9fc428ac2d8aca0fa91c9580b3d57353.tar.bz2
Code drop from //branches/cupcake/...@124589
Diffstat (limited to 'WebCore/platform/android/FileSystemAndroid.cpp')
-rw-r--r--WebCore/platform/android/FileSystemAndroid.cpp62
1 files changed, 62 insertions, 0 deletions
diff --git a/WebCore/platform/android/FileSystemAndroid.cpp b/WebCore/platform/android/FileSystemAndroid.cpp
index 1aa8843..572a9c2 100644
--- a/WebCore/platform/android/FileSystemAndroid.cpp
+++ b/WebCore/platform/android/FileSystemAndroid.cpp
@@ -29,11 +29,73 @@
#include "FileSystem.h"
#include "PlatformString.h"
#include "CString.h"
+#include <dlfcn.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include "cutils/log.h"
namespace WebCore {
+// Global static used to store the base to the plugin path.
+// This is set in WebSettings.cpp
+String sPluginPath;
+
CString fileSystemRepresentation(const String& path) {
return path.utf8();
}
+CString openTemporaryFile(const char* prefix, PlatformFileHandle& handle)
+{
+ int number = rand() % 10000 + 1;
+ CString filename;
+ do {
+ String path = sPluginPath;
+ path.append("/");
+ path.append(prefix);
+ path.append(String::number(number));
+ filename = path.utf8();
+ const char *fstr = filename.data();
+ handle = open(filename.data(), O_WRONLY | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
+ number++;
+ } while (handle == -1 && errno == EEXIST);
+
+ if (handle != -1) {
+ return filename;
+ }
+ return CString();
+}
+
+bool unloadModule(PlatformModule module)
+{
+ return dlclose(module) == 0;
+}
+
+void closeFile(PlatformFileHandle& handle)
+{
+ if (isHandleValid(handle)) {
+ close(handle);
+ handle = invalidPlatformFileHandle;
+ }
+}
+
+int writeToFile(PlatformFileHandle handle, const char* data, int length)
+{
+ int totalBytesWritten = 0;
+ while (totalBytesWritten < length) {
+ int bytesWritten = write(handle, data, length - totalBytesWritten);
+ if (bytesWritten < 0 && errno != EINTR)
+ return -1;
+ else if (bytesWritten > 0)
+ totalBytesWritten += bytesWritten;
+ }
+
+ return totalBytesWritten;
+}
+
+ // new as of SVN change 36269, Sept 8, 2008
+String homeDirectoryPath()
+{
+ return sPluginPath;
+}
+
}