Use Unicode paths instead of native paths for profile directory on platforms where native paths are not UTF-8. Bug 534854, r=ted

This commit is contained in:
Simon Montagu 2010-02-23 12:19:15 +02:00
Родитель 0b7f04f1b8
Коммит b177f7bcbf
1 изменённых файлов: 15 добавлений и 6 удалений

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

@ -69,6 +69,7 @@
#include "nsAppRunner.h"
#include "nsString.h"
#include "nsReadableUtils.h"
#include "nsNativeCharsetUtils.h"
class nsToolkitProfile : public nsIToolkitProfile
@ -656,7 +657,11 @@ nsToolkitProfileService::CreateProfile(nsILocalFile* aRootDir,
dirName = aName;
SaltProfileName(dirName);
rootDir->AppendNative(dirName);
if (NS_IsNativeUTF8()) {
rootDir->AppendNative(dirName);
} else {
rootDir->Append(NS_ConvertUTF8toUTF16(dirName));
}
}
nsCOMPtr<nsILocalFile> localDir (aLocalDir);
@ -676,7 +681,11 @@ nsToolkitProfileService::CreateProfile(nsILocalFile* aRootDir,
NS_ENSURE_TRUE(localDir, NS_ERROR_UNEXPECTED);
// use same salting
localDir->AppendNative(dirName);
if (NS_IsNativeUTF8()) {
localDir->AppendNative(dirName);
} else {
localDir->Append(NS_ConvertUTF8toUTF16(dirName));
}
}
}
@ -694,12 +703,12 @@ nsToolkitProfileService::CreateProfile(nsILocalFile* aRootDir,
else {
nsCOMPtr<nsIFile> profileDefaultsDir;
nsCOMPtr<nsIFile> profileDirParent;
nsCAutoString profileDirName;
nsAutoString profileDirName;
rv = rootDir->GetParent(getter_AddRefs(profileDirParent));
NS_ENSURE_SUCCESS(rv, rv);
rv = rootDir->GetNativeLeafName(profileDirName);
rv = rootDir->GetLeafName(profileDirName);
NS_ENSURE_SUCCESS(rv, rv);
PRBool dummy;
@ -707,8 +716,8 @@ nsToolkitProfileService::CreateProfile(nsILocalFile* aRootDir,
getter_AddRefs(profileDefaultsDir));
if (NS_SUCCEEDED(rv))
rv = profileDefaultsDir->CopyToNative(profileDirParent,
profileDirName);
rv = profileDefaultsDir->CopyTo(profileDirParent,
profileDirName);
if (NS_FAILED(rv)) {
// if copying failed, lets just ensure that the profile directory exists.
rv = rootDir->Create(nsIFile::DIRECTORY_TYPE, 0700);