Cleanup: Use exceptionless Range::* methods rather than ignoring exceptions.
[WebKit-https.git] / Source / WebCore / platform / wince / FileSystemWinCE.cpp
index 3e28a01..fb507c0 100644 (file)
 #include "config.h"
 #include "FileSystem.h"
 
+#include "FileMetadata.h"
 #include "NotImplemented.h"
-#include "PlatformString.h"
 #include <wincrypt.h>
 #include <windows.h>
 #include <wtf/text/CString.h>
+#include <wtf/text/WTFString.h>
 
 namespace WebCore {
 
@@ -68,31 +69,54 @@ static bool getFileInfo(const String& path, BY_HANDLE_FILE_INFORMATION& fileInfo
     return rtn;
 }
 
-bool getFileSize(const String& path, long long& result)
+static void getFileSizeFromFileInfo(const BY_HANDLE_FILE_INFORMATION& fileInfo, long long& size)
+{
+    ULARGE_INTEGER fileSize;
+    fileSize.LowPart = fileInfo.nFileSizeLow;
+    fileSize.HighPart = fileInfo.nFileSizeHigh;
+    size = fileSize.QuadPart;
+}
+
+static void getFileModificationTimeFromFileInfo(const BY_HANDLE_FILE_INFORMATION& fileInfo, time_t& time)
+{
+    ULARGE_INTEGER t;
+    memcpy(&t, &fileInfo.ftLastWriteTime, sizeof(t));
+    time = t.QuadPart * 0.0000001 - 11644473600.0;
+}
+
+bool getFileSize(const String& path, long long& size)
 {
     BY_HANDLE_FILE_INFORMATION fileInformation;
     if (!getFileInfo(path, fileInformation))
         return false;
 
-    ULARGE_INTEGER fileSize;
-    fileSize.LowPart = fileInformation.nFileSizeLow;
-    fileSize.HighPart = fileInformation.nFileSizeHigh;
+    getFileSizeFromFileInfo(fileInformation, size);
+    return true;
+}
 
-    result = fileSize.QuadPart;
+bool getFileModificationTime(const String& path, time_t& time)
+{
+    BY_HANDLE_FILE_INFORMATION fileInformation;
+    if (!getFileInfo(path, fileInformation))
+        return false;
 
+    getFileModificationTimeFromFileInfo(fileInformation, time);
     return true;
 }
 
-bool getFileModificationTime(const String& path, time_t& result)
+bool getFileMetadata(const String& path, FileMetadata& metadata)
 {
     BY_HANDLE_FILE_INFORMATION fileInformation;
     if (!getFileInfo(path, fileInformation))
         return false;
 
-    ULARGE_INTEGER t;
-    memcpy(&t, &fileInformation.ftLastWriteTime, sizeof(t));
-    
-    result = t.QuadPart * 0.0000001 - 11644473600.0;
+    getFileSizeFromFileInfo(fileInformation, metadata.length);
+
+    time_t modificationTime;
+    getFileModificationTimeFromFileInfo(fileInformation, modificationTime);
+    metadata.modificationTime = modificationTime;
+
+    metadata.type = (fileInformation.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? FileMetadata::TypeDirectory : FileMetadata::TypeFile;
 
     return true;
 }
@@ -310,7 +334,7 @@ Vector<String> listDirectory(const String& path, const String& filter)
             // is so far only called by PluginDatabase.cpp to list
             // all plugins in a folder, where it's not supposed to list sub-folders.
             if (!(findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
-                entries.append(root + findData.cFileName);
+                entries.append(root + String(findData.cFileName));
         } while (FindNextFile(hFind, &findData));
         FindClose(hFind);
     }