Diff
Modified: trunk/Source/Platform/ChangeLog (118480 => 118481)
--- trunk/Source/Platform/ChangeLog 2012-05-25 06:36:50 UTC (rev 118480)
+++ trunk/Source/Platform/ChangeLog 2012-05-25 06:40:17 UTC (rev 118481)
@@ -1,3 +1,17 @@
+2012-05-21 Kinuko Yasuda <[email protected]>
+
+ Cleanup: add a file system call which captures the file metadata at once.
+ https://bugs.webkit.org/show_bug.cgi?id=86995
+
+ Reviewed by David Levin.
+
+ * Platform.gypi: Added an entry for WebFileInfo.h.
+ * chromium/public/WebFileInfo.h: Renamed from Source/WebKit/chromium/public/WebFileInfo.h.
+ (WebKit::WebFileInfo::WebFileInfo):
+ * chromium/public/WebFileUtilities.h:
+ (WebKit):
+ (WebKit::WebFileUtilities::getFileInfo): Added.
+
2012-05-24 Antoine Labour <[email protected]>
[chromium] Add a setForceRenderSurface to WebLayer for test/bench purpose
Modified: trunk/Source/Platform/Platform.gypi (118480 => 118481)
--- trunk/Source/Platform/Platform.gypi 2012-05-25 06:36:50 UTC (rev 118480)
+++ trunk/Source/Platform/Platform.gypi 2012-05-25 06:40:17 UTC (rev 118481)
@@ -48,6 +48,7 @@
'chromium/public/WebData.h',
'chromium/public/WebDragData.h',
'chromium/public/WebExternalTextureLayer.h',
+ 'chromium/public/WebFileInfo.h',
'chromium/public/WebFileSystem.h',
'chromium/public/WebFileUtilities.h',
'chromium/public/WebFilterOperation.h',
Copied: trunk/Source/Platform/chromium/public/WebFileInfo.h (from rev 118480, trunk/Source/WebKit/chromium/public/WebFileInfo.h) (0 => 118481)
--- trunk/Source/Platform/chromium/public/WebFileInfo.h (rev 0)
+++ trunk/Source/Platform/chromium/public/WebFileInfo.h 2012-05-25 06:40:17 UTC (rev 118481)
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebFileInfo_h
+#define WebFileInfo_h
+
+#include "WebString.h"
+
+namespace WebKit {
+
+struct WebFileInfo {
+ // The last modification time of the file, in seconds.
+ // The value 0.0 means that the time is not set.
+ double modificationTime;
+
+ // The length of the file in bytes.
+ // The value -1 means that the length is not set.
+ long long length;
+
+ enum Type {
+ TypeUnknown = 0,
+ TypeFile,
+ TypeDirectory
+ };
+
+ Type type;
+
+ WebString platformPath;
+
+ WebFileInfo() : modificationTime(0.0), length(-1), type(TypeUnknown) { }
+};
+
+} // namespace WebKit
+
+#endif
Modified: trunk/Source/Platform/chromium/public/WebFileUtilities.h (118480 => 118481)
--- trunk/Source/Platform/chromium/public/WebFileUtilities.h 2012-05-25 06:36:50 UTC (rev 118480)
+++ trunk/Source/Platform/chromium/public/WebFileUtilities.h 2012-05-25 06:40:17 UTC (rev 118481)
@@ -41,6 +41,8 @@
namespace WebKit {
+struct WebFileInfo;
+
class WebFileUtilities {
public:
#ifdef WIN32
@@ -51,8 +53,10 @@
virtual bool fileExists(const WebString& path) { return false; }
virtual bool deleteFile(const WebString& path) { return false; }
virtual bool deleteEmptyDirectory(const WebString& path) { return false; }
+ // FIXME: Deprecate getFileSize and getFileModificationTime once getFileInfo is implemented.
virtual bool getFileSize(const WebString& path, long long& result) { return false; }
virtual bool getFileModificationTime(const WebString& path, double& result) { return false; }
+ virtual bool getFileInfo(const WebString& path, WebFileInfo& result) { return false; }
virtual WebString directoryName(const WebString& path) { return WebString(); }
virtual WebString pathByAppendingComponent(const WebString& path, const WebString& component) { return WebString(); }
virtual bool makeAllDirectories(const WebString& path) { return false; }
Modified: trunk/Source/WebCore/ChangeLog (118480 => 118481)
--- trunk/Source/WebCore/ChangeLog 2012-05-25 06:36:50 UTC (rev 118480)
+++ trunk/Source/WebCore/ChangeLog 2012-05-25 06:40:17 UTC (rev 118481)
@@ -1,3 +1,47 @@
+2012-05-21 Kinuko Yasuda <[email protected]>
+
+ Cleanup: add a file system call which captures the file metadata at once.
+ https://bugs.webkit.org/show_bug.cgi?id=86995
+
+ Reviewed by David Levin.
+
+ Current File.slice() (webkitSlice()) implementation calls two separate platform calls,
+ getFileSize() and getFileModificationTime() [both are defined in platform/FileSystem.h],
+ to capture the file metadata, but we should have a single file system call to get them at once
+ for two reasons: 1. save additional system call costs, and 2. atomically obtain the file metadata.
+
+ No new tests: existing tests (http/tests/local/fileapi/* and fast/files/*) should pass.
+
+ * fileapi/File.cpp:
+ (WebCore::File::captureSnapshot):
+ * platform/FileMetadata.h:
+ * platform/FileSystem.h:
+ * platform/chromium/FileSystemChromium.cpp:
+ (WebCore::getFileMetadata): Added.
+ * platform/chromium/PlatformSupport.h:
+ (PlatformSupport):
+ * platform/gtk/FileSystemGtk.cpp:
+ (WebCore::getFileMetadata): Added.
+ * platform/posix/FileSystemPOSIX.cpp:
+ (WebCore::getFileMetadata): Added.
+ * platform/qt/FileSystemQt.cpp:
+ (WebCore::getFileMetadata): Added.
+ * platform/win/FileSystemWin.cpp:
+ (WebCore::getFileSizeFromFindData):
+ (WebCore::getFileModificationTimeFromFindData):
+ (WebCore::getFileSize):
+ (WebCore::getFileModificationTime):
+ (WebCore::getFileMetadata): Added.
+ * platform/wince/FileSystemWinCE.cpp:
+ (WebCore::getFileSizeFromFileInfo):
+ (WebCore::getFileModificationTimeFromFileInfo):
+ (WebCore::getFileSize):
+ (WebCore::getFileModificationTime):
+ (WebCore::getFileMetadata): Added.
+ * platform/wx/FileSystemWx.cpp:
+ (WebCore::getFileMetadata): Added.
+ (WebCore):
+
2012-05-24 Hironori Bono <[email protected]>
Enable grammar checking on Chromium when we paste text (Take 2)
Modified: trunk/Source/WebCore/fileapi/File.cpp (118480 => 118481)
--- trunk/Source/WebCore/fileapi/File.cpp 2012-05-25 06:36:50 UTC (rev 118480)
+++ trunk/Source/WebCore/fileapi/File.cpp 2012-05-25 06:40:17 UTC (rev 118481)
@@ -169,13 +169,15 @@
// Obtains a snapshot of the file by capturing its current size and modification time. This is used when we slice a file for the first time.
// If we fail to retrieve the size or modification time, probably due to that the file has been deleted, 0 size is returned.
- // FIXME: Combine getFileSize and getFileModificationTime into one file system call.
- time_t modificationTime;
- if (!getFileSize(m_path, snapshotSize) || !getFileModificationTime(m_path, modificationTime)) {
+ FileMetadata metadata;
+ if (!getFileMetadata(m_path, metadata)) {
snapshotSize = 0;
snapshotModificationTime = 0;
- } else
- snapshotModificationTime = modificationTime;
+ return;
+ }
+
+ snapshotSize = metadata.length;
+ snapshotModificationTime = metadata.modificationTime;
}
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/FileMetadata.h (118480 => 118481)
--- trunk/Source/WebCore/platform/FileMetadata.h 2012-05-25 06:36:50 UTC (rev 118480)
+++ trunk/Source/WebCore/platform/FileMetadata.h 2012-05-25 06:40:17 UTC (rev 118481)
@@ -33,8 +33,6 @@
#include <wtf/text/WTFString.h>
-#if ENABLE(FILE_SYSTEM)
-
namespace WebCore {
struct FileMetadata {
@@ -54,13 +52,13 @@
Type type;
+#if ENABLE(FILE_SYSTEM)
String platformPath;
+#endif
FileMetadata() : modificationTime(0.0), length(-1), type(TypeUnknown) { }
};
} // namespace WebCore
-#endif // ENABLE(FILE_SYSTEM)
-
#endif // FileMetadata_h
Modified: trunk/Source/WebCore/platform/FileSystem.h (118480 => 118481)
--- trunk/Source/WebCore/platform/FileSystem.h 2012-05-25 06:36:50 UTC (rev 118480)
+++ trunk/Source/WebCore/platform/FileSystem.h 2012-05-25 06:40:17 UTC (rev 118481)
@@ -151,11 +151,14 @@
static const char PlatformFilePathSeparator = '/';
#endif
+struct FileMetadata;
+
bool fileExists(const String&);
bool deleteFile(const String&);
bool deleteEmptyDirectory(const String&);
bool getFileSize(const String&, long long& result);
bool getFileModificationTime(const String&, time_t& result);
+bool getFileMetadata(const String&, FileMetadata&);
String pathByAppendingComponent(const String& path, const String& component);
bool makeAllDirectories(const String& path);
String homeDirectoryPath();
Modified: trunk/Source/WebCore/platform/chromium/FileSystemChromium.cpp (118480 => 118481)
--- trunk/Source/WebCore/platform/chromium/FileSystemChromium.cpp 2012-05-25 06:36:50 UTC (rev 118480)
+++ trunk/Source/WebCore/platform/chromium/FileSystemChromium.cpp 2012-05-25 06:40:17 UTC (rev 118481)
@@ -31,6 +31,7 @@
#include "config.h"
#include "FileSystem.h"
+#include "FileMetadata.h"
#include "NotImplemented.h"
#include "PlatformString.h"
#include "PlatformSupport.h"
@@ -57,6 +58,19 @@
return PlatformSupport::getFileModificationTime(path, result);
}
+bool getFileMetadata(const String& path, FileMetadata& metadata)
+{
+ // FIXME: Call PlatformSupport::getFileMetadata once it is implemented.
+ // return PlatformSupport::getFileMetadata(path, metadata);
+ if (!PlatformSupport::getFileSize(path, metadata.length))
+ return false;
+ time_t modificationTime;
+ if (!PlatformSupport::getFileModificationTime(path, modificationTime))
+ return false;
+ metadata.modificationTime = modificationTime;
+ return true;
+}
+
String directoryName(const String& path)
{
return PlatformSupport::directoryName(path);
Modified: trunk/Source/WebCore/platform/chromium/PlatformSupport.h (118480 => 118481)
--- trunk/Source/WebCore/platform/chromium/PlatformSupport.h 2012-05-25 06:36:50 UTC (rev 118480)
+++ trunk/Source/WebCore/platform/chromium/PlatformSupport.h 2012-05-25 06:40:17 UTC (rev 118481)
@@ -128,6 +128,7 @@
static bool deleteEmptyDirectory(const String&);
static bool getFileSize(const String&, long long& result);
static bool getFileModificationTime(const String&, time_t& result);
+ static bool getFileMetadata(const String&, FileMetadata& result);
static String directoryName(const String& path);
static String pathByAppendingComponent(const String& path, const String& component);
static bool makeAllDirectories(const String& path);
Modified: trunk/Source/WebCore/platform/gtk/FileSystemGtk.cpp (118480 => 118481)
--- trunk/Source/WebCore/platform/gtk/FileSystemGtk.cpp 2012-05-25 06:36:50 UTC (rev 118480)
+++ trunk/Source/WebCore/platform/gtk/FileSystemGtk.cpp 2012-05-25 06:40:17 UTC (rev 118481)
@@ -23,14 +23,15 @@
#include "config.h"
#include "FileSystem.h"
-#include <wtf/gobject/GOwnPtr.h>
+#include "FileMetadata.h"
#include "PlatformString.h"
#include "UUID.h"
#include <gio/gio.h>
#include <glib.h>
#include <glib/gstdio.h>
+#include <wtf/gobject/GOwnPtr.h>
+#include <wtf/gobject/GRefPtr.h>
#include <wtf/gobject/GlibUtilities.h>
-#include <wtf/gobject/GRefPtr.h>
#include <wtf/text/CString.h>
namespace WebCore {
@@ -141,6 +142,24 @@
}
+bool getFileMetadata(const String& path, FileMetadata& metadata)
+{
+ CString filename = fileSystemRepresentation(path);
+ if (filename.isNull())
+ return false;
+
+ struct stat statResult;
+ gint result = g_stat(filename.data(), &statResult);
+ if (result)
+ return false;
+
+ metadata.modificationTime = statResult.st_mtime;
+ metadata.length = statResult.st_size;
+ metadata.type = S_ISDIR(statResult.st_mode) ? FileMetadata::TypeDirectory : FileMetadata::TypeFile;
+ return true;
+
+}
+
String pathByAppendingComponent(const String& path, const String& component)
{
if (path.endsWith(G_DIR_SEPARATOR_S))
Modified: trunk/Source/WebCore/platform/posix/FileSystemPOSIX.cpp (118480 => 118481)
--- trunk/Source/WebCore/platform/posix/FileSystemPOSIX.cpp 2012-05-25 06:36:50 UTC (rev 118480)
+++ trunk/Source/WebCore/platform/posix/FileSystemPOSIX.cpp 2012-05-25 06:40:17 UTC (rev 118481)
@@ -29,6 +29,7 @@
#include "config.h"
#include "FileSystem.h"
+#include "FileMetadata.h"
#include "PlatformString.h"
#include <dirent.h>
#include <errno.h>
@@ -181,6 +182,23 @@
return true;
}
+bool getFileMetadata(const String& path, FileMetadata& metadata)
+{
+ CString fsRep = fileSystemRepresentation(path);
+
+ if (!fsRep.data() || fsRep.data()[0] == '\0')
+ return false;
+
+ struct stat fileInfo;
+ if (stat(fsRep.data(), &fileInfo))
+ return false;
+
+ metadata.modificationTime = fileInfo.st_mtime;
+ metadata.length = fileInfo.st_size;
+ metadata.type = S_ISDIR(fileInfo.st_mode) ? FileMetadata::TypeDirectory : FileMetadata::TypeFile;
+ return true;
+}
+
String pathByAppendingComponent(const String& path, const String& component)
{
if (path.endsWith('/'))
Modified: trunk/Source/WebCore/platform/qt/FileSystemQt.cpp (118480 => 118481)
--- trunk/Source/WebCore/platform/qt/FileSystemQt.cpp 2012-05-25 06:36:50 UTC (rev 118480)
+++ trunk/Source/WebCore/platform/qt/FileSystemQt.cpp 2012-05-25 06:40:17 UTC (rev 118481)
@@ -33,6 +33,7 @@
#include "config.h"
#include "FileSystem.h"
+#include "FileMetadata.h"
#include "PlatformString.h"
#include <QDateTime>
#include <QDir>
@@ -73,6 +74,17 @@
return info.exists();
}
+bool getFileMetadata(const String& path, FileMetadata& result)
+{
+ QFileInfo info(path);
+ if (!info.exists())
+ return false;
+ result.modificationTime = info.lastModified().toTime_t();
+ result.length = info.size();
+ result.type = info.isDir() ? FileMetadata::TypeDirectory : FileMetadata::TypeFile;
+ return true;
+}
+
bool makeAllDirectories(const String& path)
{
return QDir::root().mkpath(path);
Modified: trunk/Source/WebCore/platform/win/FileSystemWin.cpp (118480 => 118481)
--- trunk/Source/WebCore/platform/win/FileSystemWin.cpp 2012-05-25 06:36:50 UTC (rev 118480)
+++ trunk/Source/WebCore/platform/win/FileSystemWin.cpp 2012-05-25 06:40:17 UTC (rev 118481)
@@ -30,6 +30,7 @@
#include "config.h"
#include "FileSystem.h"
+#include "FileMetadata.h"
#include "NotImplemented.h"
#include "PathWalker.h"
#include <wtf/CryptographicallyRandomNumber.h>
@@ -54,12 +55,8 @@
return true;
}
-bool getFileSize(const String& path, long long& result)
+static bool getFileSizeFromFindData(const WIN32_FIND_DATAW& findData, long long& size)
{
- WIN32_FIND_DATAW findData;
- if (!getFindData(path, findData))
- return false;
-
ULARGE_INTEGER fileSize;
fileSize.HighPart = findData.nFileSizeHigh;
fileSize.LowPart = findData.nFileSizeLow;
@@ -67,25 +64,57 @@
if (fileSize.QuadPart > static_cast<ULONGLONG>(std::numeric_limits<long long>::max()))
return false;
- result = fileSize.QuadPart;
+ size = fileSize.QuadPart;
return true;
}
-bool getFileModificationTime(const String& path, time_t& result)
+static void getFileModificationTimeFromFindData(const WIN32_FIND_DATAW& findData, time_t& time)
{
+ ULARGE_INTEGER fileTime;
+ fileTime.HighPart = findData.ftLastWriteTime.dwHighDateTime;
+ fileTime.LowPart = findData.ftLastWriteTime.dwLowDateTime;
+
+ // Information about converting time_t to FileTime is available at http://msdn.microsoft.com/en-us/library/ms724228%28v=vs.85%29.aspx
+ time = fileTime.QuadPart / 10000000 - kSecondsFromFileTimeToTimet;
+}
+
+bool getFileSize(const String& path, long long& size)
+{
WIN32_FIND_DATAW findData;
if (!getFindData(path, findData))
return false;
- ULARGE_INTEGER fileSize;
- fileSize.HighPart = findData.ftLastWriteTime.dwHighDateTime;
- fileSize.LowPart = findData.ftLastWriteTime.dwLowDateTime;
+ return getFileSizeFromFindData(findData, size);
+}
- // Information about converting time_t to FileTime is available at http://msdn.microsoft.com/en-us/library/ms724228%28v=vs.85%29.aspx
- result = fileSize.QuadPart / 10000000 - kSecondsFromFileTimeToTimet;
+bool getFileModificationTime(const String& path, time_t& time)
+{
+ WIN32_FIND_DATAW findData;
+ if (!getFindData(path, findData))
+ return false;
+
+ getFileModificationTimeFromFindData(findData, time);
return true;
}
+bool getFileMetadata(const String& path, FileMetadata& metadata)
+{
+ WIN32_FIND_DATAW findData;
+ if (!getFindData(path, findData))
+ return false;
+
+ if (!getFileSizeFromFindData(findData, metadata.length))
+ return false;
+
+ time_t modificationTime;
+ getFileModificationTimeFromFindData(findData, modificationTime);
+ metadata.modificationTime = modificationTime;
+
+ metadata.type = (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? FileMetadata::TypeDirectory : FileMetadata::TypeFile;
+
+ return true;
+}
+
bool fileExists(const String& path)
{
WIN32_FIND_DATAW findData;
Modified: trunk/Source/WebCore/platform/wince/FileSystemWinCE.cpp (118480 => 118481)
--- trunk/Source/WebCore/platform/wince/FileSystemWinCE.cpp 2012-05-25 06:36:50 UTC (rev 118480)
+++ trunk/Source/WebCore/platform/wince/FileSystemWinCE.cpp 2012-05-25 06:40:17 UTC (rev 118481)
@@ -31,6 +31,7 @@
#include "config.h"
#include "FileSystem.h"
+#include "FileMetadata.h"
#include "NotImplemented.h"
#include <wincrypt.h>
#include <windows.h>
@@ -68,32 +69,55 @@
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;
}
Modified: trunk/Source/WebCore/platform/wx/FileSystemWx.cpp (118480 => 118481)
--- trunk/Source/WebCore/platform/wx/FileSystemWx.cpp 2012-05-25 06:36:50 UTC (rev 118480)
+++ trunk/Source/WebCore/platform/wx/FileSystemWx.cpp 2012-05-25 06:40:17 UTC (rev 118481)
@@ -30,6 +30,7 @@
#include "config.h"
#include "FileSystem.h"
+#include "FileMetadata.h"
#include <wx/wx.h>
#include <wx/datetime.h>
#include <wx/dir.h>
@@ -85,6 +86,17 @@
return false;
}
+bool getFileMetadata(const String& path, FileMetadata& metadata)
+{
+ if (!wxFileExists(path))
+ return false;
+ wxFileName fileName(path);
+ metadata.length = fileName.GetSize();
+ metadata.modificationTime = fileName.GetModificationTime().GetTicks();
+ metadata.type = fileName.IsDir() ? FileMetadata::TypeDirectory : FileMetadata::TypeFile;
+ return true;
+}
+
bool makeAllDirectories(const String& path)
{
return wxFileName::Mkdir(path, 0777, wxPATH_MKDIR_FULL);
Modified: trunk/Source/WebKit/chromium/ChangeLog (118480 => 118481)
--- trunk/Source/WebKit/chromium/ChangeLog 2012-05-25 06:36:50 UTC (rev 118480)
+++ trunk/Source/WebKit/chromium/ChangeLog 2012-05-25 06:40:17 UTC (rev 118481)
@@ -1,3 +1,14 @@
+2012-05-21 Kinuko Yasuda <[email protected]>
+
+ Cleanup: add a file system call which captures the file metadata at once.
+ https://bugs.webkit.org/show_bug.cgi?id=86995
+
+ Reviewed by David Levin.
+
+ * src/PlatformSupport.cpp:
+ (WebCore::PlatformSupport::getFileMetadata):
+ (WebCore):
+
2012-05-24 Hironori Bono <[email protected]>
Enable grammar checking on Chromium when we paste text (Take 2)
Modified: trunk/Source/WebKit/chromium/WebKit.gyp (118480 => 118481)
--- trunk/Source/WebKit/chromium/WebKit.gyp 2012-05-25 06:36:50 UTC (rev 118480)
+++ trunk/Source/WebKit/chromium/WebKit.gyp 2012-05-25 06:40:17 UTC (rev 118481)
@@ -147,7 +147,6 @@
'public/WebFileChooserCompletion.h',
'public/WebFileChooserParams.h',
'public/WebFileError.h',
- 'public/WebFileInfo.h',
'public/WebFileSystemCallbacks.h',
'public/WebFileSystemEntry.h',
'public/WebFileWriter.h',
Modified: trunk/Source/WebKit/chromium/public/WebFileInfo.h (118480 => 118481)
--- trunk/Source/WebKit/chromium/public/WebFileInfo.h 2012-05-25 06:36:50 UTC (rev 118480)
+++ trunk/Source/WebKit/chromium/public/WebFileInfo.h 2012-05-25 06:40:17 UTC (rev 118481)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010 Google Inc. All rights reserved.
+ * Copyright (C) 2012 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -28,35 +28,4 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef WebFileInfo_h
-#define WebFileInfo_h
-
-#include "platform/WebString.h"
-
-namespace WebKit {
-
-struct WebFileInfo {
- // The last modification time of the file, in seconds.
- // The value 0.0 means that the time is not set.
- double modificationTime;
-
- // The length of the file in bytes.
- // The value -1 means that the length is not set.
- long long length;
-
- enum Type {
- TypeUnknown = 0,
- TypeFile,
- TypeDirectory
- };
-
- Type type;
-
- WebString platformPath;
-
- WebFileInfo() : modificationTime(0.0), length(-1), type(TypeUnknown) { }
-};
-
-} // namespace WebKit
-
-#endif
+#include "../../../Platform/chromium/public/WebFileInfo.h"
Modified: trunk/Source/WebKit/chromium/src/PlatformSupport.cpp (118480 => 118481)
--- trunk/Source/WebKit/chromium/src/PlatformSupport.cpp 2012-05-25 06:36:50 UTC (rev 118480)
+++ trunk/Source/WebKit/chromium/src/PlatformSupport.cpp 2012-05-25 06:40:17 UTC (rev 118481)
@@ -35,7 +35,9 @@
#include "Chrome.h"
#include "ChromeClientImpl.h"
+#include "FileMetadata.h"
#include "Page.h"
+#include "WebFileInfo.h"
#include "WebFileUtilities.h"
#include "WebFrameClient.h"
#include "WebFrameImpl.h"
@@ -329,6 +331,17 @@
return true;
}
+bool PlatformSupport::getFileMetadata(const String& path, FileMetadata& result)
+{
+ WebFileInfo webFileInfo;
+ if (!webKitPlatformSupport()->fileUtilities()->getFileInfo(path, webFileInfo))
+ return false;
+ result.modificationTime = webFileInfo.modificationTime;
+ result.length = webFileInfo.length;
+ result.type = static_cast<FileMetadata::Type>(webFileInfo.type);
+ return true;
+}
+
String PlatformSupport::directoryName(const String& path)
{
return WebKit::Platform::current()->fileUtilities()->directoryName(path);