最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

File System IO in Javascript using V8 - Stack Overflow

programmeradmin3浏览0评论

I was under the impression that these days javascript can be used as a proper general purpose programming language outside of the browser using standalone interpreters like V8 or SpiderMonkey. So I went ahead and installed V8.

However, the first thing I wanted to do was read in a file and do some processing. I looked around and didn't find an obvious way of doing this using JS/V8.

My intuition tells me that there has to be a wrapper function around the C++ file i/o functions in V8. Has this already been done or is this something that I need to implement myself? Or perhaps I'm missing the whole point!?

Thanks for any help you can provide!

I was under the impression that these days javascript can be used as a proper general purpose programming language outside of the browser using standalone interpreters like V8 or SpiderMonkey. So I went ahead and installed V8.

However, the first thing I wanted to do was read in a file and do some processing. I looked around and didn't find an obvious way of doing this using JS/V8.

My intuition tells me that there has to be a wrapper function around the C++ file i/o functions in V8. Has this already been done or is this something that I need to implement myself? Or perhaps I'm missing the whole point!?

Thanks for any help you can provide!

Share Improve this question edited Mar 15, 2012 at 14:49 hippietrail 17k21 gold badges109 silver badges178 bronze badges asked Dec 17, 2010 at 3:37 Tim MerrifieldTim Merrifield 6,2585 gold badges33 silver badges34 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 11

There's a project called nodeJS designed for this: http://nodejs/ - and it's just starting to bee really popular.

Examples specific to file IO are here: http://nodejs/docs/v0.2.5/api.html#file-system-104

If you're going to use nodeJS, the website only shows the core functionality, so don't forget to check out the existing libraries (called modules) built for node: https://github./ry/node/wiki/modules

The focus at the moment is on nodeJS-based web servers and network-based applications but the modules link includes many other things, including parsers, daemons, and bindings to linux's notification system (just to give you a taste of the diversity there).

JavaScript was designed for use in a web browser, so the typical operations you'd expect on a puter are conspicuously missing! However, the CommonJS project aims to create a set of standards for functions that should be available to a JavaScript environment that might exist outside the browser.

For V8 specifically, you'll have to write your own or find a library which provides the functions you're looking for. The implementations section at CommonJS might have some good links to projects which implement the current "Filesystem" proposal.

发布评论

评论列表(0)

  1. 暂无评论