diff --git a/xpcom/glue/nsStringAPI.h b/xpcom/glue/nsStringAPI.h index a1e941d52675..4072e0e8a679 100644 --- a/xpcom/glue/nsStringAPI.h +++ b/xpcom/glue/nsStringAPI.h @@ -116,6 +116,12 @@ public: { NS_StringSetData(*this, &aChar, 1); } +#ifdef MOZ_USE_CHAR16_WRAPPER + NS_HIDDEN_(void) Assign(char16ptr_t aData, size_type aLength = UINT32_MAX) + { + NS_StringSetData(*this, aData, aLength); + } +#endif NS_HIDDEN_(void) AssignLiteral(const char *aStr); NS_HIDDEN_(void) AssignASCII(const char *aStr) { AssignLiteral(aStr); } @@ -123,6 +129,9 @@ public: NS_HIDDEN_(self_type&) operator=(const self_type& aString) { Assign(aString); return *this; } NS_HIDDEN_(self_type&) operator=(const char_type* aPtr) { Assign(aPtr); return *this; } NS_HIDDEN_(self_type&) operator=(char_type aChar) { Assign(aChar); return *this; } +#ifdef MOZ_USE_CHAR16_WRAPPER + NS_HIDDEN_(self_type&) operator=(char16ptr_t aPtr) { Assign(aPtr); return *this; } +#endif NS_HIDDEN_(void) Replace( index_type cutStart, size_type cutLength, const char_type* data, size_type length = size_type(-1) ) { @@ -224,6 +233,12 @@ public: { return Equals(other); } +#ifdef MOZ_USE_CHAR16_WRAPPER + NS_HIDDEN_(bool) operator == (char16ptr_t other) const + { + return Equals(other); + } +#endif NS_HIDDEN_(bool) operator >= (const self_type &other) const { diff --git a/xpcom/io/FileUtilsWin.cpp b/xpcom/io/FileUtilsWin.cpp index 3e9c5019e1c3..d12ec8b243b9 100644 --- a/xpcom/io/FileUtilsWin.cpp +++ b/xpcom/io/FileUtilsWin.cpp @@ -49,7 +49,7 @@ HandleToFilename(HANDLE aHandle, const LARGE_INTEGER& aOffset, do { mappedFilename.SetLength(mappedFilename.Length() + MAX_PATH); len = GetMappedFileNameW(GetCurrentProcess(), view, - mappedFilename.BeginWriting(), + wwc(mappedFilename.BeginWriting()), mappedFilename.Length()); } while (!len && GetLastError() == ERROR_INSUFFICIENT_BUFFER); if (!len) { diff --git a/xpcom/io/FileUtilsWin.h b/xpcom/io/FileUtilsWin.h index 01a551fa7a16..dc94e3a7d3b6 100644 --- a/xpcom/io/FileUtilsWin.h +++ b/xpcom/io/FileUtilsWin.h @@ -35,7 +35,7 @@ NtPathToDosPath(const nsAString& aNtPath, nsAString& aDosPath) nsAutoString logicalDrives; DWORD len = 0; while(true) { - len = GetLogicalDriveStringsW(len, logicalDrives.BeginWriting()); + len = GetLogicalDriveStringsW(len, reinterpret_cast(logicalDrives.BeginWriting())); if (!len) { return false; } else if (len > logicalDrives.Length()) { @@ -56,7 +56,7 @@ NtPathToDosPath(const nsAString& aNtPath, nsAString& aDosPath) DWORD targetPathLen = 0; SetLastError(ERROR_SUCCESS); while (true) { - targetPathLen = QueryDosDeviceW(driveTemplate, targetPath.BeginWriting(), + targetPathLen = QueryDosDeviceW(driveTemplate, reinterpret_cast(targetPath.BeginWriting()), targetPath.Length()); if (targetPathLen || GetLastError() != ERROR_INSUFFICIENT_BUFFER) { break; @@ -68,7 +68,7 @@ NtPathToDosPath(const nsAString& aNtPath, nsAString& aDosPath) size_t firstTargetPathLen = wcslen(targetPath.get()); const char16_t* pathComponent = aNtPath.BeginReading() + firstTargetPathLen; - bool found = _wcsnicmp(aNtPath.BeginReading(), targetPath.get(), + bool found = _wcsnicmp(char16ptr_t(aNtPath.BeginReading()), targetPath.get(), firstTargetPathLen) == 0 && *pathComponent == L'\\'; if (found) { diff --git a/xpcom/tests/windows/TestNtPathToDosPath.cpp b/xpcom/tests/windows/TestNtPathToDosPath.cpp index 4533f7528df1..1f1d75bc41d1 100644 --- a/xpcom/tests/windows/TestNtPathToDosPath.cpp +++ b/xpcom/tests/windows/TestNtPathToDosPath.cpp @@ -10,6 +10,8 @@ #include #include "mozilla/FileUtilsWin.h" +#include "mozilla/DebugOnly.h" +#include "nsCRTGlue.h" class DriveMapping { @@ -35,8 +37,8 @@ private: }; DriveMapping::DriveMapping(const nsAString& aRemoteUNCPath) - : mRemoteUNCPath(aRemoteUNCPath) - , mDriveLetter(0) + : mDriveLetter(0) + , mRemoteUNCPath(aRemoteUNCPath) { } @@ -56,7 +58,7 @@ DriveMapping::DoMapping() NETRESOURCEW netRes = {0}; netRes.dwType = RESOURCETYPE_DISK; netRes.lpLocalName = drvTemplate; - netRes.lpRemoteName = mRemoteUNCPath.BeginWriting(); + netRes.lpRemoteName = reinterpret_cast(mRemoteUNCPath.BeginWriting()); wchar_t driveLetter = L'D'; DWORD result = NO_ERROR; do { @@ -86,7 +88,7 @@ void DriveMapping::Disconnect(wchar_t aDriveLetter) { wchar_t drvTemplate[] = {aDriveLetter, L':', L'\0'}; - DWORD result = WNetCancelConnection2W(drvTemplate, 0, TRUE); + mozilla::DebugOnly result = WNetCancelConnection2W(drvTemplate, 0, TRUE); MOZ_ASSERT(result == NO_ERROR); } @@ -104,7 +106,7 @@ DriveToNtPath(const wchar_t aDriveLetter, nsAString& aNtPath) aNtPath.SetLength(MAX_PATH); DWORD pathLen; while (true) { - pathLen = QueryDosDeviceW(drvTpl, aNtPath.BeginWriting(), aNtPath.Length()); + pathLen = QueryDosDeviceW(drvTpl, reinterpret_cast(aNtPath.BeginWriting()), aNtPath.Length()); if (pathLen || GetLastError() != ERROR_INSUFFICIENT_BUFFER) { break; } @@ -115,7 +117,7 @@ DriveToNtPath(const wchar_t aDriveLetter, nsAString& aNtPath) } // aNtPath contains embedded NULLs, so we need to figure out the real length // via wcslen. - aNtPath.SetLength(wcslen(aNtPath.BeginReading())); + aNtPath.SetLength(NS_strlen(aNtPath.BeginReading())); return true; } @@ -191,7 +193,7 @@ int main(int argc, char* argv[]) fail("Querying network drive"); return 1; } - networkPath += L"\\"; + networkPath += MOZ_UTF16("\\"); if (!TestNtPathToDosPath(networkPath.get(), expected)) { fail("Mapped UNC path"); result = 1; @@ -208,7 +210,7 @@ int main(int argc, char* argv[]) fail("Querying second network drive"); return 1; } - networkPath += L"\\"; + networkPath += MOZ_UTF16("\\"); if (!TestNtPathToDosPath(networkPath.get(), expected)) { fail("Re-mapped UNC path"); result = 1;