Most inexpensive way to get `OS.Constants` global

On the main thread, I needed to access OS.Constants.libc, however OS.Constants is not available in global bootstrap scope anymore it seems. (I so thought OS was there with only .Constants)

Anyways what would be the most inexpensive way to bring it in?

Cc["@mozilla.org/net/osfileconstantsservice;1"].getService(Ci.nsIOSFileConstantsService).init();

That uses XPCOM so I wanted to avoid that.

Firefox is built on XPCOM. If you don’t use it, you’ll be stuck with only the most basic of javascript features. One day maybe the internals will be built on something else, but don’t hold your breath.

Haha I get you. Alrighty I’ll go with xpcom, thanks brother!

Oh shoot, I posted this question at like 3AM my time. Isn’t importing JSM modules free (as long as it was imported else where)? So I can simply just do Cu.import('resoucre://gre/modules/osfile.jsm') for absolutely no cost correct?

I’m not sure what costs you’re concerned about. There is a cost to everything. This just isn’t one that I would worry about in normal situations.

1 Like