Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Implement nqp::eoffh.
  • Loading branch information
pmurias committed Dec 3, 2014
1 parent 13785ed commit 5a9057c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
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('eoffh', $T_INT, [$T_OBJ], :sideffects);
add_simple_op('readlinefh', $T_STR, [$T_OBJ], :sideffects);
add_simple_op('readallfh', $T_STR, [$T_OBJ], :sideffects);
add_simple_op('printfh', $T_OBJ, [$T_OBJ, $T_STR], :sideffects);
Expand Down
8 changes: 8 additions & 0 deletions src/vm/js/nqp-runtime/io.js
Expand Up @@ -116,6 +116,14 @@ op.tellfh = function(fh) {
return fs.seekSync(fh.fd, 0, 1);
};

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);
return current == end ? 1 : 0;
};

op.setencoding = function(fh, encoding) {
fh.encoding = encoding;
};
Expand Down

0 comments on commit 5a9057c

Please sign in to comment.