Closed Bug 684134 Opened 13 years ago Closed 11 years ago

file module can't read from resource:// URIs

Categories

(Add-on SDK Graveyard :: General, enhancement, P3)

enhancement

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: KWierso, Unassigned)

Details

(Whiteboard: [good first bug])

While trying to work on bug 682631, I wrote a sample extension to test out the new async readAll() function. I put a text file in the extension's data/ directory, and then tried to read it using file.readAll(data.url("textfile.txt"), callback);

This failed and threw an error:
[Exception... "Component returned failure code: 0x80520001 (NS_ERROR_FILE_UNRECOGNIZED_PATH) [nsILocalFile.initWithPath]"  nsresult: "0x80520001 (NS_ERROR_FILE_UNRECOGNIZED_PATH)"  location: "JS frame :: resource://jid1-osjbqfful5kyag-at-jetpack-api-utils-lib/securable-module.js -> resource://jid1-osjbqfful5kyag-at-jetpack-api-utils-lib/file.js :: MozFile :: line 64"  data: no]


I then tried it using the original sync read() function, and it threw the same error.
Severity: normal → enhancement
Priority: -- → P3
Whiteboard: [good first bug]
The sdk/url module has a toFilename method which could be used here I think.
I think we're moving towards deprecating io/file -- is this still necessary?
Flags: needinfo?(kwierso)
(In reply to Jordan Santell [:jsantell] [@jsantell] from comment #2)
> I think we're moving towards deprecating io/file -- is this still necessary?

I'll pass that question over to Irakli. :)
Flags: needinfo?(kwierso) → needinfo?(rFobic)
Yes we'll be moving to io/fs but it will have a same issue. data.url("textfile.txt") is not a file path, as a matter of fact it may even not have path as it will be under compressed .xpi file.

Now data.load("textfile.txt") can already return content of that file, unfortunately performing sync IO, but
if you want to do it async there's also:
https://github.com/mozilla/addon-sdk/blob/master/lib/sdk/net/url.js#L38
Status: NEW → RESOLVED
Closed: 11 years ago
Flags: needinfo?(rFobic)
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.