From: adele@apple.com Date: Thu, 24 Apr 2008 22:56:51 +0000 (+0000) Subject: 2008-04-24 Adele Peterson X-Git-Url: http://git.webkit.org/?p=WebKit-https.git;a=commitdiff_plain;h=fee219917c67b66209a0e12b051b714428065f18 2008-04-24 Adele Peterson Reviewed by Darin. Consolidate two versions of pathGetFileName. * html/HTMLFormElement.cpp: (WebCore::HTMLFormElement::formData): Call FileSystem.h version of pathGetFileName and removed the static helper function. * platform/posix/FileSystemPOSIX.cpp: (WebCore::pathGetFileName): Moved general case from HTMLFormElement version here. If other platforms relied on that default they should implement this function for their platform specific version of FileSystem.cpp * platform/win/FileSystemWin.cpp: (WebCore::pathGetFileName): Moved win implementation from HTMLFormElement here. * platform/wx/FileSystemWx.cpp: (WebCore::pathGetFileName): Moved wx implementation from HTMLFormElement here. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@32519 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog index 7d63f97..48e186c 100644 --- a/WebCore/ChangeLog +++ b/WebCore/ChangeLog @@ -1,3 +1,15 @@ +2008-04-24 Adele Peterson + + Reviewed by Darin. + + Consolidate two versions of pathGetFileName. + + * html/HTMLFormElement.cpp: (WebCore::HTMLFormElement::formData): Call FileSystem.h version of pathGetFileName and removed the static helper function. + * platform/posix/FileSystemPOSIX.cpp: (WebCore::pathGetFileName): Moved general case from HTMLFormElement version here. + If other platforms relied on that default they should implement this function for their platform specific version of FileSystem.cpp + * platform/win/FileSystemWin.cpp: (WebCore::pathGetFileName): Moved win implementation from HTMLFormElement here. + * platform/wx/FileSystemWx.cpp: (WebCore::pathGetFileName): Moved wx implementation from HTMLFormElement here. + 2008-04-24 Anders Carlsson Windows build fix. diff --git a/WebCore/html/HTMLFormElement.cpp b/WebCore/html/HTMLFormElement.cpp index 708ff91..b15c62d 100644 --- a/WebCore/html/HTMLFormElement.cpp +++ b/WebCore/html/HTMLFormElement.cpp @@ -28,6 +28,7 @@ #include "CSSHelper.h" #include "Event.h" #include "EventNames.h" +#include "FileSystem.h" #include "FormData.h" #include "FormDataList.h" #include "Frame.h" @@ -207,24 +208,6 @@ static int randomNumber() #endif } -// FIXME: Move to platform directory? -// Warning: this helper doesn't currently have a reliable cross-platform behavior in -// certain edge cases (see basename(3) specification for examples). -// Consider this if it ever needs to become a general purpose method. -static String pathGetFilename(const String& path) -{ -#if PLATFORM(QT) - return QFileInfo(path).fileName(); -#elif PLATFORM(WX) - return wxFileName(path).GetFullName(); -#elif PLATFORM(WIN_OS) - String copy(path); - return String(::PathFindFileName(copy.charactersWithNullTermination())); -#else - return path.substring(path.reverseFind('/') + 1); -#endif -} - TextEncoding HTMLFormElement::dataEncoding() const { if (isMailtoForm()) @@ -285,7 +268,7 @@ PassRefPtr HTMLFormElement::formData(const char* boundary) const if (control->hasLocalName(inputTag) && static_cast(control)->inputType() == HTMLInputElement::FILE) { String path = static_cast(control)->value(); - String filename = pathGetFilename(path); + String filename = pathGetFileName(path); // FIXME: This won't work if the filename includes a " mark, // or control characters like CR or LF. This also does strange diff --git a/WebCore/platform/posix/FileSystemPOSIX.cpp b/WebCore/platform/posix/FileSystemPOSIX.cpp index 84e731d..fd7fdc9 100644 --- a/WebCore/platform/posix/FileSystemPOSIX.cpp +++ b/WebCore/platform/posix/FileSystemPOSIX.cpp @@ -141,4 +141,9 @@ bool makeAllDirectories(const String& path) return true; } +String pathGetFileName(const String& path) +{ + return path.substring(path.reverseFind('/') + 1); +} + } // namespace WebCore diff --git a/WebCore/platform/win/FileSystemWin.cpp b/WebCore/platform/win/FileSystemWin.cpp index 2a6c5d1..26219f3 100644 --- a/WebCore/platform/win/FileSystemWin.cpp +++ b/WebCore/platform/win/FileSystemWin.cpp @@ -128,7 +128,7 @@ String homeDirectoryPath() String pathGetFileName(const String& path) { - return String(PathFindFileName(String(path).charactersWithNullTermination())); + return String(::PathFindFileName(String(path).charactersWithNullTermination())); } static String bundleName() diff --git a/WebCore/platform/wx/FileSystemWx.cpp b/WebCore/platform/wx/FileSystemWx.cpp index 7be985b..4ef3efc 100644 --- a/WebCore/platform/wx/FileSystemWx.cpp +++ b/WebCore/platform/wx/FileSystemWx.cpp @@ -83,10 +83,9 @@ String homeDirectoryPath() return String(); } -String pathGetFileName(const String&) +String pathGetFileName(const String& path) { - notImplemented(); - return String(); + return wxFileName(path).GetFullName(); } CString openTemporaryFile(const char* prefix, PlatformFileHandle& handle)