The default bug view has changed. See this FAQ.

initWithPath fails for "~"

RESOLVED FIXED in mozilla14

Status

()

Core
XPCOM
RESOLVED FIXED
5 years ago
5 years ago

People

(Reporter: mano, Assigned: mano)

Tracking

unspecified
mozilla14
x86
Mac OS X
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

initWithPath("~/Downloads") - works.
initWithPath("~/Downloads/") - works.
initWithPath("~/") - works.
initWithPath("~") - does not work.
Created attachment 615066 [details] [diff] [review]
patch + test
Assignee: nobody → mano
Status: NEW → ASSIGNED
Attachment #615066 - Flags: superreview?(bzbarsky)
Attachment #615066 - Flags: review?(bzbarsky)
This is necessary for bug 710259 (for importing the Downloads folder if it's set to the user's home folder).
Comment on attachment 615066 [details] [diff] [review]
patch + test

r=me, but this needs a separate sr
Attachment #615066 - Flags: superreview?(bzbarsky)
Attachment #615066 - Flags: superreview?(benjamin)
Attachment #615066 - Flags: review?(bzbarsky)
Attachment #615066 - Flags: review+
Comment on attachment 615066 [details] [diff] [review]
patch + test

Thanks Boris.

>-    if (Substring(filePath, 0, 2).EqualsLiteral("~/")) {
>+    if (filePath.Equals("~") || Substring(filePath, 0, 2).EqualsLiteral("~/")) {
>         nsCOMPtr<nsIFile> homeDir;
>         nsCAutoString homePath;
>         if (NS_FAILED(NS_GetSpecialDirectory(NS_OS_HOME_DIR,
>                                              getter_AddRefs(homeDir))) ||
>             NS_FAILED(homeDir->GetNativePath(homePath))) {
>             return NS_ERROR_FAILURE;
>         }
>-        
>-        mPath = homePath + Substring(filePath, 1, filePath.Length() - 1);
>+ 
>+        mPath = homePath;
>+        if (filePath.Length() > 1)
>+          mPath.Append(Substring(filePath, 1, filePath.Length() - 1));
>     } else {


That shoukd have been > 2 (or could have been, it does not hurt as it is now).
Attachment #615066 - Flags: superreview?(benjamin) → superreview+
http://hg.mozilla.org/integration/mozilla-inbound/rev/0d48714f4773
Target Milestone: --- → mozilla14
https://hg.mozilla.org/mozilla-central/rev/0d48714f4773
Status: ASSIGNED → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → FIXED
and the follow-up
https://hg.mozilla.org/mozilla-central/rev/296b90f063d5
You need to log in before you can comment on or make changes to this bug.