-/*\r
- * Copyright (C) 2007 Apple Inc. All rights reserved.\r
+/*
+ * Copyright (C) 2007 Apple Inc. All rights reserved.
* Copyright (C) 2008 Collabora, Ltd. All rights reserved.
- *\r
- * Redistribution and use in source and binary forms, with or without\r
- * modification, are permitted provided that the following conditions\r
- * are met:\r
- *\r
- * 1. Redistributions of source code must retain the above copyright\r
- * notice, this list of conditions and the following disclaimer. \r
- * 2. Redistributions in binary form must reproduce the above copyright\r
- * notice, this list of conditions and the following disclaimer in the\r
- * documentation and/or other materials provided with the distribution. \r
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of\r
- * its contributors may be used to endorse or promote products derived\r
- * from this software without specific prior written permission. \r
- *\r
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY\r
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY\r
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\r
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\r
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
- */\r
-\r
-#include "config.h"\r
-#include "FileSystem.h"\r
-\r
-#include "CString.h"\r
-#include "NotImplemented.h"\r
-#include "PlatformString.h"\r
-\r
-#include <windows.h>\r
-#include <winbase.h>\r
-#include <shlobj.h>\r
-#include <shlwapi.h>\r
-\r
-namespace WebCore {\r
-\r
-bool fileSize(const String& path, long long& result)\r
-{\r
- struct _stat32i64 sb;\r
- String filename = path;\r
- int statResult = _wstat32i64(filename.charactersWithNullTermination(), &sb);\r
- if (statResult != 0 || (sb.st_mode & S_IFMT) != S_IFREG)\r
- return false;\r
- result = sb.st_size;\r
- return true;\r
-}\r
-\r
-bool fileExists(const String& path) \r
-{\r
- struct _stat32i64 sb;\r
- String filename = path;\r
- return !_wstat32i64(filename.charactersWithNullTermination(), &sb);\r
-}\r
-\r
-bool deleteFile(const String& path)\r
-{\r
- String filename = path;\r
- return !!DeleteFileW(filename.charactersWithNullTermination());\r
-}\r
-\r
-String pathByAppendingComponent(const String& path, const String& component)\r
-{\r
- Vector<UChar> buffer(MAX_PATH);\r
-\r
- if (path.length() + 1 > buffer.size())\r
- return String();\r
-\r
- memcpy(buffer.data(), path.characters(), path.length() * sizeof(UChar));\r
- buffer[path.length()] = '\0';\r
-\r
- String componentCopy = component;\r
- if (!PathAppendW(buffer.data(), componentCopy.charactersWithNullTermination()))\r
- return String();\r
-\r
- buffer.resize(wcslen(buffer.data()));\r
-\r
- return String::adopt(buffer);\r
-}\r
-\r
-CString fileSystemRepresentation(const String&)\r
-{\r
- return "";\r
-}\r
-\r
-bool makeAllDirectories(const String& path)\r
-{\r
- String fullPath = path;\r
- if (SHCreateDirectoryEx(0, fullPath.charactersWithNullTermination(), 0) != ERROR_SUCCESS) {\r
- DWORD error = GetLastError();\r
- if (error != ERROR_FILE_EXISTS && error != ERROR_ALREADY_EXISTS) {\r
- LOG_ERROR("Failed to create path %s", path.ascii().data());\r
- return false;\r
- }\r
- }\r
- return true;\r
-}\r
-\r
-String homeDirectoryPath()\r
-{\r
- notImplemented();\r
- return "";\r
-}\r
-\r
-static String bundleName()\r
-{\r
- static bool initialized;\r
- static String name = "WebKit";\r
-\r
- if (!initialized) {\r
- initialized = true;\r
-\r
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") 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 APPLE AND ITS 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 APPLE OR ITS 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.
+ */
+
+#include "config.h"
+#include "FileSystem.h"
+
+#include "CString.h"
+#include "NotImplemented.h"
+#include "PlatformString.h"
+
+#include <windows.h>
+#include <winbase.h>
+#include <shlobj.h>
+#include <shlwapi.h>
+
+namespace WebCore {
+
+bool fileSize(const String& path, long long& result)
+{
+ struct _stat32i64 sb;
+ String filename = path;
+ int statResult = _wstat32i64(filename.charactersWithNullTermination(), &sb);
+ if (statResult != 0 || (sb.st_mode & S_IFMT) != S_IFREG)
+ return false;
+ result = sb.st_size;
+ return true;
+}
+
+bool fileExists(const String& path)
+{
+ struct _stat32i64 sb;
+ String filename = path;
+ return !_wstat32i64(filename.charactersWithNullTermination(), &sb);
+}
+
+bool deleteFile(const String& path)
+{
+ String filename = path;
+ return !!DeleteFileW(filename.charactersWithNullTermination());
+}
+
+String pathByAppendingComponent(const String& path, const String& component)
+{
+ Vector<UChar> buffer(MAX_PATH);
+
+ if (path.length() + 1 > buffer.size())
+ return String();
+
+ memcpy(buffer.data(), path.characters(), path.length() * sizeof(UChar));
+ buffer[path.length()] = '\0';
+
+ String componentCopy = component;
+ if (!PathAppendW(buffer.data(), componentCopy.charactersWithNullTermination()))
+ return String();
+
+ buffer.resize(wcslen(buffer.data()));
+
+ return String::adopt(buffer);
+}
+
+CString fileSystemRepresentation(const String&)
+{
+ return "";
+}
+
+bool makeAllDirectories(const String& path)
+{
+ String fullPath = path;
+ if (SHCreateDirectoryEx(0, fullPath.charactersWithNullTermination(), 0) != ERROR_SUCCESS) {
+ DWORD error = GetLastError();
+ if (error != ERROR_FILE_EXISTS && error != ERROR_ALREADY_EXISTS) {
+ LOG_ERROR("Failed to create path %s", path.ascii().data());
+ return false;
+ }
+ }
+ return true;
+}
+
+String homeDirectoryPath()
+{
+ notImplemented();
+ return "";
+}
+
+static String bundleName()
+{
+ static bool initialized;
+ static String name = "WebKit";
+
+ if (!initialized) {
+ initialized = true;
+
if (CFBundleRef bundle = CFBundleGetMainBundle())
if (CFTypeRef bundleExecutable = CFBundleGetValueForInfoDictionaryKey(bundle, kCFBundleExecutableKey))
if (CFGetTypeID(bundleExecutable) == CFStringGetTypeID())
- name = reinterpret_cast<CFStringRef>(bundleExecutable);\r
- }\r
-\r
- return name;\r
-}\r
-\r
+ name = reinterpret_cast<CFStringRef>(bundleExecutable);
+ }
+
+ return name;
+}
+
static String storageDirectory(DWORD pathIdentifier)
{
Vector<UChar> buffer(MAX_PATH);
return String();
return directory;
-}\r
-\r
-static String cachedStorageDirectory(DWORD pathIdentifier)\r
-{\r
- static HashMap<DWORD, String> directories;\r
-\r
- HashMap<DWORD, String>::iterator it = directories.find(pathIdentifier);\r
- if (it != directories.end())\r
- return it->second;\r
-\r
- String directory = storageDirectory(pathIdentifier);\r
- directories.add(pathIdentifier, directory);\r
-\r
- return directory;\r
-}\r
-\r
+}
+
+static String cachedStorageDirectory(DWORD pathIdentifier)
+{
+ static HashMap<DWORD, String> directories;
+
+ HashMap<DWORD, String>::iterator it = directories.find(pathIdentifier);
+ if (it != directories.end())
+ return it->second;
+
+ String directory = storageDirectory(pathIdentifier);
+ directories.add(pathIdentifier, directory);
+
+ return directory;
+}
+
CString openTemporaryFile(const char* prefix, PlatformFileHandle& handle)
{
return true;
}
-\r
-} // namespace WebCore\r
+
+} // namespace WebCore