Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix nqp::eoffh. Implement nqp::seekfh.
  • Loading branch information
pmurias committed Dec 3, 2014
1 parent 5a9057c commit 1cf4ad3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/vm/js/QAST/Compiler.nqp
Expand Up @@ -374,6 +374,7 @@ class QAST::OperationsJS {
add_simple_op('open', $T_OBJ, [$T_STR, $T_STR], :sideffects);

add_simple_op('tellfh', $T_INT, [$T_OBJ], :sideffects);
add_simple_op('seekfh', $T_INT, [$T_OBJ, $T_INT, $T_INT], :sideffects);
add_simple_op('eoffh', $T_INT, [$T_OBJ], :sideffects);
add_simple_op('readlinefh', $T_STR, [$T_OBJ], :sideffects);
add_simple_op('readallfh', $T_STR, [$T_OBJ], :sideffects);
Expand Down
6 changes: 5 additions & 1 deletion src/vm/js/nqp-runtime/io.js
Expand Up @@ -120,7 +120,7 @@ op.eoffh = function(fh) {
// I haven't found a way to implement this directly in node.js
var current = fs.seekSync(fh.fd, 0, 1);
var end = fs.seekSync(fh.fd, 0, 2);
fs.seekSync(fh.fd, 0, current);
fs.seekSync(fh.fd, current, 0);
return current == end ? 1 : 0;
};

Expand Down Expand Up @@ -170,6 +170,10 @@ op.readallfh = function(fh) {
return iconv.decode(all, fh.encoding);
};

op.seekfh = function(fh, offset, whence) {
fs.seekSync(fh.fd, offset, whence);
};

op.closefh = function(fh) {
fh.closefh();
return fh;
Expand Down

0 comments on commit 1cf4ad3

Please sign in to comment.