зеркало из https://github.com/mozilla/gecko-dev.git
Bug 971646 - FileUtilsWin.h fails to compile on GCC. r=bsmedberg
This commit is contained in:
Родитель
1375c609c7
Коммит
52f8916e46
|
@ -116,6 +116,12 @@ public:
|
||||||
{
|
{
|
||||||
NS_StringSetData(*this, &aChar, 1);
|
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) AssignLiteral(const char *aStr);
|
||||||
NS_HIDDEN_(void) AssignASCII(const char *aStr) { AssignLiteral(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 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=(const char_type* aPtr) { Assign(aPtr); return *this; }
|
||||||
NS_HIDDEN_(self_type&) operator=(char_type aChar) { Assign(aChar); 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) )
|
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);
|
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
|
NS_HIDDEN_(bool) operator >= (const self_type &other) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -49,7 +49,7 @@ HandleToFilename(HANDLE aHandle, const LARGE_INTEGER& aOffset,
|
||||||
do {
|
do {
|
||||||
mappedFilename.SetLength(mappedFilename.Length() + MAX_PATH);
|
mappedFilename.SetLength(mappedFilename.Length() + MAX_PATH);
|
||||||
len = GetMappedFileNameW(GetCurrentProcess(), view,
|
len = GetMappedFileNameW(GetCurrentProcess(), view,
|
||||||
mappedFilename.BeginWriting(),
|
wwc(mappedFilename.BeginWriting()),
|
||||||
mappedFilename.Length());
|
mappedFilename.Length());
|
||||||
} while (!len && GetLastError() == ERROR_INSUFFICIENT_BUFFER);
|
} while (!len && GetLastError() == ERROR_INSUFFICIENT_BUFFER);
|
||||||
if (!len) {
|
if (!len) {
|
||||||
|
|
|
@ -35,7 +35,7 @@ NtPathToDosPath(const nsAString& aNtPath, nsAString& aDosPath)
|
||||||
nsAutoString logicalDrives;
|
nsAutoString logicalDrives;
|
||||||
DWORD len = 0;
|
DWORD len = 0;
|
||||||
while(true) {
|
while(true) {
|
||||||
len = GetLogicalDriveStringsW(len, logicalDrives.BeginWriting());
|
len = GetLogicalDriveStringsW(len, reinterpret_cast<wchar_t*>(logicalDrives.BeginWriting()));
|
||||||
if (!len) {
|
if (!len) {
|
||||||
return false;
|
return false;
|
||||||
} else if (len > logicalDrives.Length()) {
|
} else if (len > logicalDrives.Length()) {
|
||||||
|
@ -56,7 +56,7 @@ NtPathToDosPath(const nsAString& aNtPath, nsAString& aDosPath)
|
||||||
DWORD targetPathLen = 0;
|
DWORD targetPathLen = 0;
|
||||||
SetLastError(ERROR_SUCCESS);
|
SetLastError(ERROR_SUCCESS);
|
||||||
while (true) {
|
while (true) {
|
||||||
targetPathLen = QueryDosDeviceW(driveTemplate, targetPath.BeginWriting(),
|
targetPathLen = QueryDosDeviceW(driveTemplate, reinterpret_cast<wchar_t*>(targetPath.BeginWriting()),
|
||||||
targetPath.Length());
|
targetPath.Length());
|
||||||
if (targetPathLen || GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
|
if (targetPathLen || GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
|
||||||
break;
|
break;
|
||||||
|
@ -68,7 +68,7 @@ NtPathToDosPath(const nsAString& aNtPath, nsAString& aDosPath)
|
||||||
size_t firstTargetPathLen = wcslen(targetPath.get());
|
size_t firstTargetPathLen = wcslen(targetPath.get());
|
||||||
const char16_t* pathComponent = aNtPath.BeginReading() +
|
const char16_t* pathComponent = aNtPath.BeginReading() +
|
||||||
firstTargetPathLen;
|
firstTargetPathLen;
|
||||||
bool found = _wcsnicmp(aNtPath.BeginReading(), targetPath.get(),
|
bool found = _wcsnicmp(char16ptr_t(aNtPath.BeginReading()), targetPath.get(),
|
||||||
firstTargetPathLen) == 0 &&
|
firstTargetPathLen) == 0 &&
|
||||||
*pathComponent == L'\\';
|
*pathComponent == L'\\';
|
||||||
if (found) {
|
if (found) {
|
||||||
|
|
|
@ -10,6 +10,8 @@
|
||||||
#include <winnetwk.h>
|
#include <winnetwk.h>
|
||||||
|
|
||||||
#include "mozilla/FileUtilsWin.h"
|
#include "mozilla/FileUtilsWin.h"
|
||||||
|
#include "mozilla/DebugOnly.h"
|
||||||
|
#include "nsCRTGlue.h"
|
||||||
|
|
||||||
class DriveMapping
|
class DriveMapping
|
||||||
{
|
{
|
||||||
|
@ -35,8 +37,8 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
DriveMapping::DriveMapping(const nsAString& aRemoteUNCPath)
|
DriveMapping::DriveMapping(const nsAString& aRemoteUNCPath)
|
||||||
: mRemoteUNCPath(aRemoteUNCPath)
|
: mDriveLetter(0)
|
||||||
, mDriveLetter(0)
|
, mRemoteUNCPath(aRemoteUNCPath)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +58,7 @@ DriveMapping::DoMapping()
|
||||||
NETRESOURCEW netRes = {0};
|
NETRESOURCEW netRes = {0};
|
||||||
netRes.dwType = RESOURCETYPE_DISK;
|
netRes.dwType = RESOURCETYPE_DISK;
|
||||||
netRes.lpLocalName = drvTemplate;
|
netRes.lpLocalName = drvTemplate;
|
||||||
netRes.lpRemoteName = mRemoteUNCPath.BeginWriting();
|
netRes.lpRemoteName = reinterpret_cast<wchar_t*>(mRemoteUNCPath.BeginWriting());
|
||||||
wchar_t driveLetter = L'D';
|
wchar_t driveLetter = L'D';
|
||||||
DWORD result = NO_ERROR;
|
DWORD result = NO_ERROR;
|
||||||
do {
|
do {
|
||||||
|
@ -86,7 +88,7 @@ void
|
||||||
DriveMapping::Disconnect(wchar_t aDriveLetter)
|
DriveMapping::Disconnect(wchar_t aDriveLetter)
|
||||||
{
|
{
|
||||||
wchar_t drvTemplate[] = {aDriveLetter, L':', L'\0'};
|
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);
|
MOZ_ASSERT(result == NO_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,7 +106,7 @@ DriveToNtPath(const wchar_t aDriveLetter, nsAString& aNtPath)
|
||||||
aNtPath.SetLength(MAX_PATH);
|
aNtPath.SetLength(MAX_PATH);
|
||||||
DWORD pathLen;
|
DWORD pathLen;
|
||||||
while (true) {
|
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) {
|
if (pathLen || GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
|
||||||
break;
|
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
|
// aNtPath contains embedded NULLs, so we need to figure out the real length
|
||||||
// via wcslen.
|
// via wcslen.
|
||||||
aNtPath.SetLength(wcslen(aNtPath.BeginReading()));
|
aNtPath.SetLength(NS_strlen(aNtPath.BeginReading()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,7 +193,7 @@ int main(int argc, char* argv[])
|
||||||
fail("Querying network drive");
|
fail("Querying network drive");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
networkPath += L"\\";
|
networkPath += MOZ_UTF16("\\");
|
||||||
if (!TestNtPathToDosPath(networkPath.get(), expected)) {
|
if (!TestNtPathToDosPath(networkPath.get(), expected)) {
|
||||||
fail("Mapped UNC path");
|
fail("Mapped UNC path");
|
||||||
result = 1;
|
result = 1;
|
||||||
|
@ -208,7 +210,7 @@ int main(int argc, char* argv[])
|
||||||
fail("Querying second network drive");
|
fail("Querying second network drive");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
networkPath += L"\\";
|
networkPath += MOZ_UTF16("\\");
|
||||||
if (!TestNtPathToDosPath(networkPath.get(), expected)) {
|
if (!TestNtPathToDosPath(networkPath.get(), expected)) {
|
||||||
fail("Re-mapped UNC path");
|
fail("Re-mapped UNC path");
|
||||||
result = 1;
|
result = 1;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче