Last Comment Bug 745466 - initWithPath fails for "~"
: initWithPath fails for "~"
Status: RESOLVED FIXED
:
Product: Core
Classification: Components
Component: XPCOM (show other bugs)
: unspecified
: x86 Mac OS X
: -- normal (vote)
: mozilla14
Assigned To: Mano (::mano, needinfo? for any questions; not reading general bugmail)
:
Mentors:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-04-14 10:20 PDT by Mano (::mano, needinfo? for any questions; not reading general bugmail)
Modified: 2012-04-17 07:31 PDT (History)
4 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
patch + test (2.03 KB, patch)
2012-04-14 10:47 PDT, Mano (::mano, needinfo? for any questions; not reading general bugmail)
bzbarsky: review+
benjamin: superreview+
Details | Diff | Splinter Review

Description Mano (::mano, needinfo? for any questions; not reading general bugmail) 2012-04-14 10:20:21 PDT
initWithPath("~/Downloads") - works.
initWithPath("~/Downloads/") - works.
initWithPath("~/") - works.
initWithPath("~") - does not work.
Comment 1 Mano (::mano, needinfo? for any questions; not reading general bugmail) 2012-04-14 10:47:04 PDT
Created attachment 615066 [details] [diff] [review]
patch + test
Comment 2 Mano (::mano, needinfo? for any questions; not reading general bugmail) 2012-04-14 10:48:29 PDT
This is necessary for bug 710259 (for importing the Downloads folder if it's set to the user's home folder).
Comment 3 Boris Zbarsky [:bz] 2012-04-15 18:08:06 PDT
Comment on attachment 615066 [details] [diff] [review]
patch + test

r=me, but this needs a separate sr
Comment 4 Mano (::mano, needinfo? for any questions; not reading general bugmail) 2012-04-15 22:10:43 PDT
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).
Comment 5 Mano (::mano, needinfo? for any questions; not reading general bugmail) 2012-04-16 11:41:42 PDT
http://hg.mozilla.org/integration/mozilla-inbound/rev/0d48714f4773
Comment 6 Marco Bonardo [::mak] (Away 6-20 Aug) 2012-04-17 07:24:02 PDT
https://hg.mozilla.org/mozilla-central/rev/0d48714f4773
Comment 7 Marco Bonardo [::mak] (Away 6-20 Aug) 2012-04-17 07:31:22 PDT
and the follow-up
https://hg.mozilla.org/mozilla-central/rev/296b90f063d5

Note You need to log in before you can comment on or make changes to this bug.