mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 745466 - initWithPath fails for "~". r=bz. sr=bsmedberg.
This commit is contained in:
parent
1559635ebd
commit
163327fae2
@ -334,7 +334,7 @@ nsLocalFile::Clone(nsIFile **file)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsLocalFile::InitWithNativePath(const nsACString &filePath)
|
nsLocalFile::InitWithNativePath(const nsACString &filePath)
|
||||||
{
|
{
|
||||||
if (Substring(filePath, 0, 2).EqualsLiteral("~/")) {
|
if (filePath.Equals("~") || Substring(filePath, 0, 2).EqualsLiteral("~/")) {
|
||||||
nsCOMPtr<nsIFile> homeDir;
|
nsCOMPtr<nsIFile> homeDir;
|
||||||
nsCAutoString homePath;
|
nsCAutoString homePath;
|
||||||
if (NS_FAILED(NS_GetSpecialDirectory(NS_OS_HOME_DIR,
|
if (NS_FAILED(NS_GetSpecialDirectory(NS_OS_HOME_DIR,
|
||||||
@ -342,8 +342,10 @@ nsLocalFile::InitWithNativePath(const nsACString &filePath)
|
|||||||
NS_FAILED(homeDir->GetNativePath(homePath))) {
|
NS_FAILED(homeDir->GetNativePath(homePath))) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
mPath = homePath + Substring(filePath, 1, filePath.Length() - 1);
|
mPath = homePath;
|
||||||
|
if (filePath.Length() > 2)
|
||||||
|
mPath.Append(Substring(filePath, 1, filePath.Length() - 1));
|
||||||
} else {
|
} else {
|
||||||
if (filePath.IsEmpty() || filePath.First() != '/')
|
if (filePath.IsEmpty() || filePath.First() != '/')
|
||||||
return NS_ERROR_FILE_UNRECOGNIZED_PATH;
|
return NS_ERROR_FILE_UNRECOGNIZED_PATH;
|
||||||
|
6
xpcom/tests/unit/test_bug745466.js
Normal file
6
xpcom/tests/unit/test_bug745466.js
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
Components.utils.import("resource://gre/modules/FileUtils.jsm");
|
||||||
|
|
||||||
|
function run_test()
|
||||||
|
{
|
||||||
|
do_check_true(FileUtils.File("~").equals(FileUtils.getDir("Home", [])));
|
||||||
|
}
|
@ -45,3 +45,4 @@ fail-if = os == "android"
|
|||||||
[test_versioncomparator.js]
|
[test_versioncomparator.js]
|
||||||
[test_comp_no_aslr.js]
|
[test_comp_no_aslr.js]
|
||||||
fail-if = os != "win"
|
fail-if = os != "win"
|
||||||
|
[test_bug745466.js]
|
||||||
|
Loading…
Reference in New Issue
Block a user