Open
Bug 476326
Opened 17 years ago
Updated 3 years ago
nsICommandLine::resolveFile doesn't resolve to absolute path for macOS
Categories
(Toolkit :: Startup and Profile System, defect)
Tracking
()
NEW
People
(Reporter: myk, Unassigned)
Details
Attachments
(1 file)
|
2.48 KB,
application/x-zip-compressed
|
Details |
According to its documentation <http://mxr.mozilla.org/mozilla/source/toolkit/components/commandlines/public/nsICommandLine.idl?mark=159-166#160>, nsICommandLine::resolveFile "gracefully handles relative or absolute file paths, according to the working directory of this command line."
That's what happens on Windows and Linux, but on Mac OS X the method doesn't handle relative paths gracefully. Instead, it returns an nsIFile whose path attribute is not resolved relative to the working directory (i.e. nsIFile::path is a relative path, not an absolute one, and calling nsIFile::exists() returns false even if the file exists).
I've attached a XULRunner app that demonstrates the problem. It does this:
let cmdLine = window.arguments[0].QueryInterface(Components.interfaces.nsICommandLine);
let arg = cmdLine.handleFlagWithParam("f", false);
let file = cmdLine.resolveFile(arg);
dump("Resolved argument " + arg + " to nsIFile with path " + file.path + ", which does" + (file.exists() ? "" : " not") + " exist.\n");
goQuitApplication();
Steps to reproduce:
1. download and unzip testcase
2. touch foo
3. /Library/Frameworks/XUL.framework/xulrunner-bin -app /absolute/path/to/resolveFileTestcase/application.ini -f foo
Expected results: alert "Resolved argument foo to nsIFile with path /absolute/path/to/foo, which does exist."
Actual results: alert "Resolved argument foo to nsIFile with path foo, which does not exist."
Comment 1•17 years ago
|
||
I see this too and I've been using the following to work around it for now:
file = commandLine.resolveURI(outfile)
.QueryInterface(Ci.nsIFileURL).file;
Updated•4 years ago
|
Summary: nsICommandLine::resolveFile doesn't resolve to absolute path → nsICommandLine::resolveFile doesn't resolve to absolute path for macOS
Updated•3 years ago
|
Severity: normal → S3
You need to log in
before you can comment on or make changes to this bug.
Description
•