зеркало из https://github.com/mozilla/pjs.git
Bug 458252: local file paths are wrong on windows mobile r=dougt sr=bsmedberg
This commit is contained in:
Родитель
37719af365
Коммит
beead28e86
|
@ -58,8 +58,14 @@ net_GetURLSpecFromFile(nsIFile *aFile, nsACString &result)
|
||||||
path.ReplaceChar(PRUnichar(0x5Cu), PRUnichar(0x2Fu));
|
path.ReplaceChar(PRUnichar(0x5Cu), PRUnichar(0x2Fu));
|
||||||
|
|
||||||
nsCAutoString escPath;
|
nsCAutoString escPath;
|
||||||
|
|
||||||
|
// Windows Desktop paths beging with a drive letter, so need an 'extra'
|
||||||
|
// slash at the begining
|
||||||
|
#ifdef WINCE // /Windows => file:///Windows
|
||||||
|
NS_NAMED_LITERAL_CSTRING(prefix, "file://");
|
||||||
|
#else // C:\Windows => file:///C:/Windows
|
||||||
NS_NAMED_LITERAL_CSTRING(prefix, "file:///");
|
NS_NAMED_LITERAL_CSTRING(prefix, "file:///");
|
||||||
|
#endif
|
||||||
// Escape the path with the directory mask
|
// Escape the path with the directory mask
|
||||||
NS_ConvertUTF16toUTF8 ePath(path);
|
NS_ConvertUTF16toUTF8 ePath(path);
|
||||||
if (NS_EscapeURL(ePath.get(), -1, esc_Directory+esc_Forced, escPath))
|
if (NS_EscapeURL(ePath.get(), -1, esc_Directory+esc_Forced, escPath))
|
||||||
|
@ -133,9 +139,11 @@ net_GetFileFromURLSpec(const nsACString &aURL, nsIFile **result)
|
||||||
if (path.Length() != strlen(path.get()))
|
if (path.Length() != strlen(path.get()))
|
||||||
return NS_ERROR_FILE_INVALID_PATH;
|
return NS_ERROR_FILE_INVALID_PATH;
|
||||||
|
|
||||||
|
#ifndef WINCE
|
||||||
// remove leading '\'
|
// remove leading '\'
|
||||||
if (path.CharAt(0) == '\\')
|
if (path.CharAt(0) == '\\')
|
||||||
path.Cut(0, 1);
|
path.Cut(0, 1);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (IsUTF8(path))
|
if (IsUTF8(path))
|
||||||
rv = localFile->InitWithPath(NS_ConvertUTF8toUTF16(path));
|
rv = localFile->InitWithPath(NS_ConvertUTF8toUTF16(path));
|
||||||
|
|
|
@ -900,12 +900,16 @@ nsLocalFile::InitWithPath(const nsAString &filePath)
|
||||||
PRUnichar *path = nsnull;
|
PRUnichar *path = nsnull;
|
||||||
PRInt32 pathLen = 0;
|
PRInt32 pathLen = 0;
|
||||||
|
|
||||||
if ( ( (secondChar == L':') && !FindCharInReadable(L'/', begin, end) ) || // normal path
|
if ((
|
||||||
#ifdef WINCE
|
!FindCharInReadable(L'/', begin, end) ) //normal path
|
||||||
( (firstChar == L'\\') ) // wince absolute path or network path
|
#ifndef WINCE
|
||||||
|
&& (secondChar == L':') || // additional normal path condition
|
||||||
|
(secondChar == L'\\') && // addtional network path condition
|
||||||
#else
|
#else
|
||||||
( (firstChar == L'\\') && (secondChar == L'\\') ) // network path
|
||
|
||||||
#endif
|
#endif
|
||||||
|
(firstChar == L'\\') // wince absolute path or network path
|
||||||
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// This is a native path
|
// This is a native path
|
||||||
|
|
Загрузка…
Ссылка в новой задаче