简体   繁体   中英

How do I get the real filesystem path from within RingoJS webapp?

If I manage to get ServletContext object from java's HttpRequest, I'd manage to accomplish this, but I couldn't find out how to access these objects from Ringo wrappers.

This is needed to create a file inside the webapp with some saved information. The relative paths correspond to different absolute paths in different enviroment, so we need to find the webapp absolute filesystem path.

It looks like you can use module.resolve() to get the directory the current module is in. I assume you could just append the module name afterwards, like so:

var fs = require('fs');

var path = fs.join(module.resolve(), 'module-name.js');

I'm trying to find out a better way - no one on the IRC seems to respond, but I'll update this answer if I succeed.

EDIT #1 : I can't seem to find a simpler way, and it doesn't look like Rhino or ECMAScript 5 supports this natively .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM