Reviewed by Kevin Ollivier.
authorkevino@webkit.org <kevino@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 Apr 2011 19:14:33 +0000 (19:14 +0000)
committerkevino@webkit.org <kevino@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 Apr 2011 19:14:33 +0000 (19:14 +0000)
[wx] Implement support for temporary files.

https://bugs.webkit.org/show_bug.cgi?id=57772

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@82851 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/FileSystem.h
Source/WebCore/platform/wx/FileSystemWx.cpp

index 793a2aa..cfa0c83 100644 (file)
@@ -1,3 +1,18 @@
+2011-04-04  Malcolm MacLeod  <mmacleod@webmail.co.za>
+
+        Reviewed by Kevin Ollivier.
+
+        [wx] Implement support for temporary files.
+        
+        https://bugs.webkit.org/show_bug.cgi?id=57772
+
+        * platform/FileSystem.h:
+        * platform/wx/FileSystemWx.cpp:
+        (WebCore::getFileModificationTime):
+        (WebCore::openTemporaryFile):
+        (WebCore::closeFile):
+        (WebCore::writeToFile):
+
 2011-04-01  Oliver Hunt  <oliver@apple.com>
 
         Reviewed by Geoffrey Garen.
index 49a78e8..a2fd588 100644 (file)
 #endif
 #endif
 
+#if PLATFORM(WX)
+#include <wx/defs.h>
+#include <wx/file.h>
+#endif
+
 #if USE(CF) || (PLATFORM(QT) && defined(Q_WS_MAC))
 typedef struct __CFBundle* CFBundleRef;
 typedef const struct __CFData* CFDataRef;
@@ -128,6 +133,9 @@ const PlatformFileHandle invalidPlatformFileHandle = 0;
 #elif PLATFORM(GTK)
 typedef GFileIOStream* PlatformFileHandle;
 const PlatformFileHandle invalidPlatformFileHandle = 0;
+#elif PLATFORM(WX)
+typedef wxFile* PlatformFileHandle;
+const PlatformFileHandle invalidPlatformFileHandle = 0;
 #else
 typedef int PlatformFileHandle;
 const PlatformFileHandle invalidPlatformFileHandle = -1;
index 3c2b453..7d21fde 100644 (file)
@@ -78,8 +78,11 @@ bool getFileSize(const String& path, long long& resultSize)
 
 bool getFileModificationTime(const String& path, time_t& t)
 {
-    t = wxFileName(path).GetModificationTime().GetTicks();
-    return true;
+    if (wxFileExists(path)) {
+        t = wxFileName(path).GetModificationTime().GetTicks();
+        return true;
+    }
+    return false;
 }
 
 bool makeAllDirectories(const String& path)
@@ -107,22 +110,26 @@ String directoryName(const String& path)
     return wxFileName(path).GetPath();
 }
 
-String openTemporaryFile(const String&, PlatformFileHandle& handle)
+String openTemporaryFile(const String& prefix, PlatformFileHandle& handle)
 {
-    notImplemented();
-    handle = invalidPlatformFileHandle;
-    return String();
+    wxString sFilename = wxFileName::CreateTempFileName(prefix);
+    wxFile* temp = new wxFile();
+    temp->Open(sFilename.c_str(), wxFile::read_write);
+    handle = temp;
+    return String(sFilename);
 }
 
-void closeFile(PlatformFileHandle&)
+void closeFile(PlatformFileHandle& handle)
 {
-    notImplemented();
+    if (handle)
+        delete handle;
 }
 
-int writeToFile(PlatformFileHandle, const char* data, int length)
+int writeToFile(PlatformFileHandle handle, const char* data, int length)
 {
-    notImplemented();
-    return 0;
+    if (handle)
+        return handle->Write(data, length);
+    return -1;
 }
 
 bool unloadModule(PlatformModule mod)