fixes bug 142870 "nsIFile should use UCS-2 instead of UTF-8"
r=dougt sr=alecf git-svn-id: svn://10.0.0.236/trunk@121010 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -27,7 +27,6 @@
|
||||
#include "nsMemory.h"
|
||||
|
||||
#include "nsLocalFileWin.h"
|
||||
#include "nsLocalFileUnicode.h"
|
||||
|
||||
#include "nsISimpleEnumerator.h"
|
||||
#include "nsIComponentManager.h"
|
||||
@@ -1935,7 +1934,7 @@ nsLocalFile::Reveal()
|
||||
nsresult rv = NS_OK;
|
||||
PRBool isDirectory = PR_FALSE;
|
||||
nsCAutoString path;
|
||||
nsCAutoString utf8Path;
|
||||
nsAutoString unicodePath;
|
||||
|
||||
IsDirectory(&isDirectory);
|
||||
if (isDirectory)
|
||||
@@ -1949,12 +1948,10 @@ nsLocalFile::Reveal()
|
||||
if (parent)
|
||||
{
|
||||
parent->GetNativePath(path);
|
||||
parent->GetPath(utf8Path);
|
||||
parent->GetPath(unicodePath);
|
||||
}
|
||||
}
|
||||
|
||||
NS_ConvertUTF8toUCS2 unicodePath(utf8Path);
|
||||
|
||||
// Remember the current fg window.
|
||||
HWND origWin, fgWin;
|
||||
origWin = fgWin = ::GetForegroundWindow();
|
||||
@@ -2030,8 +2027,8 @@ nsLocalFile::Reveal()
|
||||
break;
|
||||
|
||||
// Now get file name pidl from that folder.
|
||||
nsXPIDLString unicodeLeaf;
|
||||
if (NS_FAILED(GetUnicodeLeafName(getter_Copies(unicodeLeaf))))
|
||||
nsAutoString unicodeLeaf;
|
||||
if (NS_FAILED(GetLeafName(unicodeLeaf)))
|
||||
break;
|
||||
rc = folder->ParseDisplayName( 0,
|
||||
0,
|
||||
@@ -2210,10 +2207,10 @@ static nsresult FStoUCS2(const char* aBuffer, PRUnichar **aResult)
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsLocalFile::InitWithUnicodePath(const PRUnichar *filePath)
|
||||
nsLocalFile::InitWithPath(const nsAString &filePath)
|
||||
{
|
||||
nsXPIDLCString tmp;
|
||||
nsresult rv = UCS2toFS(filePath, getter_Copies(tmp));
|
||||
nsresult rv = UCS2toFS(PromiseFlatString(filePath).get(), getter_Copies(tmp));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
return InitWithNativePath(tmp);
|
||||
|
||||
@@ -2221,10 +2218,10 @@ nsLocalFile::InitWithUnicodePath(const PRUnichar *filePath)
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsLocalFile::AppendUnicode(const PRUnichar *node)
|
||||
nsLocalFile::Append(const nsAString &node)
|
||||
{
|
||||
nsXPIDLCString tmp;
|
||||
nsresult rv = UCS2toFS(node, getter_Copies(tmp));
|
||||
nsresult rv = UCS2toFS(PromiseFlatString(node).get(), getter_Copies(tmp));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
return AppendNative(tmp);
|
||||
|
||||
@@ -2232,31 +2229,35 @@ nsLocalFile::AppendUnicode(const PRUnichar *node)
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsLocalFile::AppendRelativeUnicodePath(const PRUnichar *node)
|
||||
nsLocalFile::AppendRelativePath(const nsAString &node)
|
||||
{
|
||||
nsXPIDLCString tmp;
|
||||
nsresult rv = UCS2toFS(node, getter_Copies(tmp));
|
||||
nsresult rv = UCS2toFS(PromiseFlatString(node).get(), getter_Copies(tmp));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
return AppendRelativeNativePath(tmp);
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsLocalFile::GetUnicodeLeafName(PRUnichar **aLeafName)
|
||||
nsLocalFile::GetLeafName(nsAString &aLeafName)
|
||||
{
|
||||
nsCAutoString tmp;
|
||||
nsresult rv = GetNativeLeafName(tmp);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
return FStoUCS2(tmp.get(), aLeafName);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsXPIDLString ucsBuf;
|
||||
rv = FStoUCS2(tmp.get(), getter_Copies(ucsBuf));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
aLeafName = ucsBuf;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsLocalFile::SetUnicodeLeafName(const PRUnichar * aLeafName)
|
||||
nsLocalFile::SetLeafName(const nsAString &aLeafName)
|
||||
{
|
||||
nsXPIDLCString tmp;
|
||||
nsresult rv = UCS2toFS(aLeafName, getter_Copies(tmp));
|
||||
nsresult rv = UCS2toFS(PromiseFlatString(aLeafName).get(), getter_Copies(tmp));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
return SetNativeLeafName(tmp);
|
||||
|
||||
@@ -2264,19 +2265,23 @@ nsLocalFile::SetUnicodeLeafName(const PRUnichar * aLeafName)
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsLocalFile::GetUnicodePath(PRUnichar **_retval)
|
||||
nsLocalFile::GetPath(nsAString &_retval)
|
||||
{
|
||||
return FStoUCS2(mWorkingPath.get(), _retval);
|
||||
nsXPIDLString ucsBuf;
|
||||
nsresult rv = FStoUCS2(mWorkingPath.get(), getter_Copies(ucsBuf));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
_retval = ucsBuf;
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsLocalFile::CopyToUnicode(nsIFile *newParentDir, const PRUnichar *newName)
|
||||
nsLocalFile::CopyTo(nsIFile *newParentDir, const nsAString &newName)
|
||||
{
|
||||
if (!newName)
|
||||
if (newName.IsEmpty())
|
||||
return CopyToNative(newParentDir, nsCString());
|
||||
|
||||
nsXPIDLCString tmp;
|
||||
nsresult rv = UCS2toFS(newName, getter_Copies(tmp));
|
||||
nsresult rv = UCS2toFS(PromiseFlatString(newName).get(), getter_Copies(tmp));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
return CopyToNative(newParentDir, tmp);
|
||||
|
||||
@@ -2284,13 +2289,13 @@ nsLocalFile::CopyToUnicode(nsIFile *newParentDir, const PRUnichar *newName)
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsLocalFile::CopyToFollowingLinksUnicode(nsIFile *newParentDir, const PRUnichar *newName)
|
||||
nsLocalFile::CopyToFollowingLinks(nsIFile *newParentDir, const nsAString &newName)
|
||||
{
|
||||
if (!newName)
|
||||
if (newName.IsEmpty())
|
||||
return CopyToFollowingLinksNative(newParentDir, nsCString());
|
||||
|
||||
nsXPIDLCString tmp;
|
||||
nsresult rv = UCS2toFS(newName, getter_Copies(tmp));
|
||||
nsresult rv = UCS2toFS(PromiseFlatString(newName).get(), getter_Copies(tmp));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
return CopyToFollowingLinksNative(newParentDir, tmp);
|
||||
|
||||
@@ -2298,13 +2303,13 @@ nsLocalFile::CopyToFollowingLinksUnicode(nsIFile *newParentDir, const PRUnichar
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsLocalFile::MoveToUnicode(nsIFile *newParentDir, const PRUnichar *newName)
|
||||
nsLocalFile::MoveTo(nsIFile *newParentDir, const nsAString &newName)
|
||||
{
|
||||
if (!newName)
|
||||
if (newName.IsEmpty())
|
||||
return MoveToNative(newParentDir, nsCString());
|
||||
|
||||
nsXPIDLCString tmp;
|
||||
nsresult rv = UCS2toFS(newName, getter_Copies(tmp));
|
||||
nsresult rv = UCS2toFS(PromiseFlatString(newName).get(), getter_Copies(tmp));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
return MoveToNative(newParentDir, tmp);
|
||||
|
||||
@@ -2312,21 +2317,25 @@ nsLocalFile::MoveToUnicode(nsIFile *newParentDir, const PRUnichar *newName)
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsLocalFile::GetUnicodeTarget(PRUnichar **_retval)
|
||||
nsLocalFile::GetTarget(nsAString &_retval)
|
||||
{
|
||||
nsCAutoString tmp;
|
||||
nsresult rv = GetNativeTarget(tmp);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
return FStoUCS2(tmp.get(), _retval);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsXPIDLString ucsBuf;
|
||||
rv = FStoUCS2(tmp.get(), getter_Copies(ucsBuf));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
_retval = ucsBuf;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_NewUnicodeLocalFile(const PRUnichar* path, PRBool followLinks, nsILocalFile* *result)
|
||||
NS_NewLocalFile(const nsAString &path, PRBool followLinks, nsILocalFile* *result)
|
||||
{
|
||||
nsXPIDLCString tmp;
|
||||
nsresult rv = UCS2toFS(path, getter_Copies(tmp));
|
||||
nsresult rv = UCS2toFS(PromiseFlatString(path).get(), getter_Copies(tmp));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
return NS_NewNativeLocalFile(tmp, followLinks, result);
|
||||
|
||||
@@ -2337,15 +2346,11 @@ NS_NewUnicodeLocalFile(const PRUnichar* path, PRBool followLinks, nsILocalFile*
|
||||
// nsLocalFile <static members>
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
PRBool nsLocalFile::mFSCharsetIsUTF8 = PR_FALSE;
|
||||
|
||||
void
|
||||
nsLocalFile::GlobalInit()
|
||||
{
|
||||
nsresult rv = NS_CreateShortcutResolver();
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "Shortcut resolver could not be created");
|
||||
|
||||
// XXX determine value of mFSCharsetIsUTF8
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
Reference in New Issue
Block a user