If you think a bug might affect users in the 57 release, please set the correct tracking and status flags for Release Management.

sdk/io/fs functions do not work with relative paths

RESOLVED INCOMPLETE

Status

Add-on SDK
General
P2
normal
RESOLVED INCOMPLETE
4 years ago
11 days ago

People

(Reporter: jsantell, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

In node's fs module, relative paths work with their functions:

`fs.writeFileSync('here.txt', 'content')`

Which would write to $PWD/here.txt. The same does not work in our SDK, as it needs an absolute path, since it is ultimately passed into an nsILocalFile, nsIFileOutputStream, or other similar functions.
What would you evaluate it relative to?
node does it relative to `__dirname` -- not sure if we can do something similar, especially with a xpi'd addon.
I don't know what __dirname is. Unless fs can read inside xpi files then making it relative to main.js wouldn't make sense. Neither would making it relative to the XPI really. Relative to the profile is about the only thing I can think of.

Updated

4 years ago
Priority: -- → P2
(Reporter)

Updated

4 years ago
Blocks: 935215
https://bugzilla.mozilla.org/show_bug.cgi?id=1399562
Status: NEW → RESOLVED
Last Resolved: 11 days ago
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.