Modified: trunk/Source/WebCore/ChangeLog (108242 => 108243)
--- trunk/Source/WebCore/ChangeLog 2012-02-20 15:23:14 UTC (rev 108242)
+++ trunk/Source/WebCore/ChangeLog 2012-02-20 16:40:24 UTC (rev 108243)
@@ -1,3 +1,16 @@
+2012-02-20 Patrick Gansterer <par...@webkit.org>
+
+ [WIN] Share openTemporaryFile with WinCE
+ https://bugs.webkit.org/show_bug.cgi?id=58750
+
+ Reviewed by Adam Roben.
+
+ Use pathByAppendingComponent instead of PathCombine to share the
+ code with WinCE. Also use the wide version of Windows functions.
+
+ * platform/win/FileSystemWin.cpp:
+ (WebCore::openTemporaryFile):
+
2012-02-20 Victor Carbune <vic...@rosedu.org>
Added code to support dispatching of missed cues in case of normal playback
Modified: trunk/Source/WebCore/platform/win/FileSystemWin.cpp (108242 => 108243)
--- trunk/Source/WebCore/platform/win/FileSystemWin.cpp 2012-02-20 15:23:14 UTC (rev 108242)
+++ trunk/Source/WebCore/platform/win/FileSystemWin.cpp 2012-02-20 16:40:24 UTC (rev 108243)
@@ -194,8 +194,8 @@
{
handle = INVALID_HANDLE_VALUE;
- char tempPath[MAX_PATH];
- int tempPathLength = ::GetTempPathA(WTF_ARRAY_LENGTH(tempPath), tempPath);
+ wchar_t tempPath[MAX_PATH];
+ int tempPathLength = ::GetTempPathW(WTF_ARRAY_LENGTH(tempPath), tempPath);
if (tempPathLength <= 0 || tempPathLength > WTF_ARRAY_LENGTH(tempPath))
return String();
@@ -203,11 +203,11 @@
if (!CryptAcquireContext(&hCryptProv, 0, 0, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT))
return String();
- char proposedPath[MAX_PATH];
- while (1) {
- char tempFile[] = "XXXXXXXX.tmp"; // Use 8.3 style name (more characters aren't helpful due to 8.3 short file names)
+ String proposedPath;
+ do {
+ wchar_t tempFile[] = L"XXXXXXXX.tmp"; // Use 8.3 style name (more characters aren't helpful due to 8.3 short file names)
const int randomPartLength = 8;
- if (!CryptGenRandom(hCryptProv, randomPartLength, reinterpret_cast<BYTE*>(tempFile)))
+ if (!CryptGenRandom(hCryptProv, randomPartLength * sizeof(wchar_t), reinterpret_cast<BYTE*>(tempFile)))
break;
// Limit to valid filesystem characters, also excluding others that could be problematic, like punctuation.
@@ -216,25 +216,22 @@
for (int i = 0; i < randomPartLength; ++i)
tempFile[i] = validChars[tempFile[i] % (sizeof(validChars) - 1)];
- ASSERT(strlen(tempFile) == sizeof(tempFile) - 1);
+ ASSERT(wcslen(tempFile) == WTF_ARRAY_LENGTH(tempFile) - 1);
- if (!PathCombineA(proposedPath, tempPath, tempFile))
+ proposedPath = pathByAppendingComponent(tempPath, tempFile);
+ if (proposedPath.isEmpty())
break;
-
+
// use CREATE_NEW to avoid overwriting an existing file with the same name
- handle = CreateFileA(proposedPath, GENERIC_READ | GENERIC_WRITE, 0, 0, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0);
- if (!isHandleValid(handle) && GetLastError() == ERROR_ALREADY_EXISTS)
- continue;
+ handle = ::CreateFileW(proposedPath.charactersWithNullTermination(), GENERIC_READ | GENERIC_WRITE, 0, 0, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0);
+ } while (!isHandleValid(handle) && GetLastError() == ERROR_ALREADY_EXISTS);
- break;
- }
-
CryptReleaseContext(hCryptProv, 0);
if (!isHandleValid(handle))
return String();
- return String::fromUTF8(proposedPath);
+ return proposedPath;
}
PlatformFileHandle openFile(const String& path, FileOpenMode mode)