WebCore/ChangeLog

 12010-06-06 Kwang Yul Seo <skyul@company100.net>
 2
 3 Reviewed by NOBODY (OOPS!).
 4
 5 Unify fileSystemRepresentation and filenameFromString
 6 https://bugs.webkit.org/show_bug.cgi?id=40201
 7
 8 Remove filenameFromString and use fileSystemRepresentation instead
 9 as they do the same job.
 10
 11 * platform/FileSystem.cpp: Removed.
 12 * platform/FileSystem.h:
 13 * platform/efl/FileSystemEfl.cpp:
 14 (WebCore::fileSystemRepresentation):
 15 * platform/gtk/FileChooserGtk.cpp:
 16 (WebCore::FileChooser::basenameForWidth):
 17 * platform/gtk/FileSystemGtk.cpp:
 18 (WebCore::fileSystemRepresentation):
 19 (WebCore::filenameForDisplay):
 20 (WebCore::fileExists):
 21 (WebCore::deleteFile):
 22 (WebCore::deleteEmptyDirectory):
 23 (WebCore::getFileSize):
 24 (WebCore::getFileModificationTime):
 25 (WebCore::makeAllDirectories):
 26 (WebCore::pathGetFileName):
 27 (WebCore::directoryName):
 28 (WebCore::listDirectory):
 29 * platform/gtk/SharedBufferGtk.cpp:
 30 (WebCore::SharedBuffer::createWithContentsOfFile):
 31 * platform/network/soup/ResourceHandleSoup.cpp:
 32 (WebCore::startHttp):
 33 * platform/posix/SharedBufferPOSIX.cpp:
 34 (WebCore::SharedBuffer::createWithContentsOfFile):
 35
1362010-06-06 Gavin Barraclough <barraclough@apple.com>
237
338 Reviewed by NOBODY (Qt build fix pt 2).
60766

WebCore/platform/FileSystem.cpp

1 /*
2  * Copyright (C) 2010 Company 100, Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 
26 #include "config.h"
27 #include "FileSystem.h"
28 
29 #include <wtf/text/CString.h>
30 
31 namespace WebCore {
32 
33 #if !PLATFORM(GTK) && !PLATFORM(EFL)
34 CString filenameFromString(const String& string)
35 {
36  return string.utf8();
37 }
38 #endif
39 
40 } // namespace WebCore
60766

WebCore/platform/FileSystem.h

@@String roamingUserSpecificStorageDirecto
172172bool safeCreateFile(const String&, CFDataRef);
173173#endif
174174
175 CString filenameFromString(const String&);
176 
177175#if PLATFORM(GTK)
178176String filenameToString(const char*);
179177String filenameForDisplay(const String&);
60766

WebCore/platform/efl/FileSystemEfl.cpp

@@namespace WebCore {
5353
5454CString fileSystemRepresentation(const String& path)
5555{
56  return path.utf8();
57 }
58 
59 CString filenameFromString(const String& string)
60 {
6156// WARNING: this is just used by platform/network/soup, thus must be GLIB!!!
6257// TODO: move this to CString and use it instead in both, being more standard
6358#if PLATFORM(WIN_OS)
60766

WebCore/platform/gtk/FileChooserGtk.cpp

@@String FileChooser::basenameForWidth(con
5757 String string = fileButtonNoFileSelectedLabel();
5858
5959 if (m_filenames.size() == 1) {
60  CString systemFilename = filenameFromString(m_filenames[0]);
 60 CString systemFilename = fileSystemRepresentation(m_filenames[0]);
6161 gchar* systemBasename = g_path_get_basename(systemFilename.data());
6262 stringByAdoptingFileSystemRepresentation(systemBasename, string);
6363 } else if (m_filenames.size() > 1)
60728

WebCore/platform/gtk/FileSystemGtk.cpp

@@String filenameToString(const char* file
5252#endif
5353}
5454
55 CString filenameFromString(const String& string)
 55CString fileSystemRepresentation(const String& path)
5656{
5757#if OS(WINDOWS)
5858 return string.utf8();

@@String filenameForDisplay(const String&
7070#if OS(WINDOWS)
7171 return string;
7272#else
73  CString filename = filenameFromString(string);
 73 CString filename = fileSystemRepresentation(string);
7474 gchar* display = g_filename_to_utf8(filename.data(), 0, 0, 0, 0);
7575 if (!display)
7676 return string;

@@String filenameForDisplay(const String&
8585bool fileExists(const String& path)
8686{
8787 bool result = false;
88  CString filename = filenameFromString(path);
 88 CString filename = fileSystemRepresentation(path);
8989
9090 if (!filename.isNull())
9191 result = g_file_test(filename.data(), G_FILE_TEST_EXISTS);

@@bool fileExists(const String& path)
9696bool deleteFile(const String& path)
9797{
9898 bool result = false;
99  CString filename = filenameFromString(path);
 99 CString filename = fileSystemRepresentation(path);
100100
101101 if (!filename.isNull())
102102 result = g_remove(filename.data()) == 0;

@@bool deleteFile(const String& path)
107107bool deleteEmptyDirectory(const String& path)
108108{
109109 bool result = false;
110  CString filename = filenameFromString(path);
 110 CString filename = fileSystemRepresentation(path);
111111
112112 if (!filename.isNull())
113113 result = g_rmdir(filename.data()) == 0;

@@bool deleteEmptyDirectory(const String&
117117
118118bool getFileSize(const String& path, long long& resultSize)
119119{
120  CString filename = filenameFromString(path);
 120 CString filename = fileSystemRepresentation(path);
121121 if (filename.isNull())
122122 return false;
123123

@@bool getFileSize(const String& path, lon
132132
133133bool getFileModificationTime(const String& path, time_t& modifiedTime)
134134{
135  CString filename = filenameFromString(path);
 135 CString filename = fileSystemRepresentation(path);
136136 if (filename.isNull())
137137 return false;
138138

@@String pathByAppendingComponent(const St
156156
157157bool makeAllDirectories(const String& path)
158158{
159  CString filename = filenameFromString(path);
 159 CString filename = fileSystemRepresentation(path);
160160 if (filename.isNull())
161161 return false;
162162

@@String pathGetFileName(const String& pat
175175 if (pathName.isEmpty())
176176 return pathName;
177177
178  CString tmpFilename = filenameFromString(pathName);
 178 CString tmpFilename = fileSystemRepresentation(pathName);
179179 char* baseName = g_path_get_basename(tmpFilename.data());
180180 String fileName = String::fromUTF8(baseName);
181181 g_free(baseName);

@@String pathGetFileName(const String& pat
186186String directoryName(const String& path)
187187{
188188 /* No null checking needed */
189  GOwnPtr<char> tmpFilename(const_cast<char*>(filenameFromString(path).data()));
 189 GOwnPtr<char> tmpFilename(const_cast<char*>(fileSystemRepresentation(path).data()));
190190 GOwnPtr<char> dirname(g_path_get_dirname(tmpFilename.get()));
191191 return String::fromUTF8(dirname.get());
192192}

@@Vector<String> listDirectory(const Strin
195195{
196196 Vector<String> entries;
197197
198  CString filename = filenameFromString(path);
 198 CString filename = fileSystemRepresentation(path);
199199 GDir* dir = g_dir_open(filename.data(), 0, 0);
200200 if (!dir)
201201 return entries;
60728

WebCore/platform/gtk/SharedBufferGtk.cpp

@@PassRefPtr<SharedBuffer> SharedBuffer::c
3232 if (filePath.isEmpty())
3333 return 0;
3434
35  CString filename = filenameFromString(filePath);
 35 CString filename = fileSystemRepresentation(filePath);
3636 gchar* contents;
3737 gsize size;
3838 GError* error = 0;
60728

WebCore/platform/network/soup/ResourceHandleSoup.cpp

@@static bool startHttp(ResourceHandle* ha
533533 * libsoup's simple-httpd test
534534 */
535535 GError* error = 0;
536  CString fileName = filenameFromString(element.m_filename);
 536 CString fileName = fileSystemRepresentation(element.m_filename);
537537 GMappedFile* fileMapping = g_mapped_file_new(fileName.data(), false, &error);
538538
539539 if (error) {
60728

WebCore/platform/posix/SharedBufferPOSIX.cpp

@@PassRefPtr<SharedBuffer> SharedBuffer::c
4040 if (filePath.isEmpty())
4141 return 0;
4242
43  CString filename = filenameFromString(filePath);
 43 CString filename = fileSystemRepresentation(filePath);
4444 int fd = open(filename.data(), O_RDONLY);
4545 if (fd == -1)
4646 return 0;
60728