Bug #66868 --> Location of profile is incorrect shown when the path contains non-ascii chars

Patch by Mike Kaply

r=dougt
sr=tor


git-svn-id: svn://10.0.0.236/trunk@150864 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
scott%scott-macgregor.org
2004-01-04 04:44:01 +00:00
parent df4d4c1169
commit fbb9b97c0b
3 changed files with 33 additions and 2 deletions

View File

@@ -992,7 +992,7 @@ function getFormElementValue(formElement) {
formElement.getAttribute("datatype") == "nsIFileSpec") {
if (formElement.value) {
var filespec = Components.classes["@mozilla.org/filespec;1"].createInstance(Components.interfaces.nsIFileSpec);
filespec.nativePath = formElement.value;
filespec.setUnicodePath(formElement.value);
return filespec;
}
return null;
@@ -1065,7 +1065,7 @@ function setFormElementValue(formElement, value) {
if (value) {
var filespec = value.QueryInterface(Components.interfaces.nsIFileSpec);
try {
formElement.value = filespec.nativePath;
formElement.value = filespec.getUnicodePath();
} catch (ex) {
dump("Still need to fix uninitialized filespec problem!\n");
}

View File

@@ -42,6 +42,7 @@
#include "nsFileStream.h"
#include "nsILocalFile.h"
#include "nsNativeCharsetUtils.h"
#include "prmem.h"
@@ -211,6 +212,34 @@ NS_IMETHODIMP nsFileSpecImpl::SetNativePath(const char * aNativePath)
return NS_OK;
}
//----------------------------------------------------------------------------------------
NS_IMETHODIMP nsFileSpecImpl::GetUnicodePath(PRUnichar * *aUnicodePath)
//----------------------------------------------------------------------------------------
{
TEST_OUT_PTR(aUnicodePath)
nsAutoString unicode;
nsCAutoString native;
native = mFileSpec.GetNativePathCString();
NS_CopyNativeToUnicode(native, unicode);
*aUnicodePath = nsCRT::strdup(unicode.get());
if (!*aUnicodePath)
return NS_ERROR_OUT_OF_MEMORY;
return NS_OK;
}
//----------------------------------------------------------------------------------------
NS_IMETHODIMP nsFileSpecImpl::SetUnicodePath(const PRUnichar * aUnicodePath)
//----------------------------------------------------------------------------------------
{
nsAutoString unicode;
nsCAutoString native;
unicode = aUnicodePath;
NS_CopyUnicodeToNative(unicode, native);
mFileSpec = native.get();
return NS_OK;
}
//----------------------------------------------------------------------------------------
NS_IMETHODIMP nsFileSpecImpl::GetNSPRPath(char * *aNSPRPath)
//----------------------------------------------------------------------------------------

View File

@@ -154,6 +154,8 @@ interface nsIFileSpec : nsISupports
void seek(in long offset);
long tell();
void endLine();
wstring getUnicodePath();
void setUnicodePath(in wstring aUnicodePath);
};