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)

x86
macOS
defect

Tracking

()

People

(Reporter: myk, Unassigned)

Details

Attachments

(1 file)

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."
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;
Summary: nsICommandLine::resolveFile doesn't resolve to absolute path → nsICommandLine::resolveFile doesn't resolve to absolute path for macOS
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: