Bug 971646 - FileUtilsWin.h fails to compile on GCC. r=bsmedberg

This commit is contained in:
Jacek Caban 2014-02-13 11:25:26 +01:00
Родитель 1375c609c7
Коммит 52f8916e46
4 изменённых файлов: 29 добавлений и 12 удалений

Просмотреть файл

@ -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
{

Просмотреть файл

@ -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) {

Просмотреть файл

@ -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<wchar_t*>(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<wchar_t*>(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) {

Просмотреть файл

@ -10,6 +10,8 @@
#include <winnetwk.h>
#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<wchar_t*>(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<DWORD> 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<wchar_t*>(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;