MCPcopy
hub / github.com/jvilk/BrowserFS / ___syscall220

Function ___syscall220

test/tests/emscripten/readdir_empty.js:5620–5659  ·  view source on GitHub ↗
(which, varargs)

Source from the content-addressed store, hash-verified

5618 }
5619
5620 function ___syscall220(which, varargs) {SYSCALLS.varargs = varargs;
5621 try {
5622 // SYS_getdents64
5623 var stream = SYSCALLS.getStreamFromFD(), dirp = SYSCALLS.get(), count = SYSCALLS.get();
5624 if (!stream.getdents) {
5625 stream.getdents = FS.readdir(stream.path);
5626 }
5627 var pos = 0;
5628 while (stream.getdents.length > 0 && pos + 268 < count) {
5629 var id;
5630 var type;
5631 var name = stream.getdents.pop();
5632 assert(name.length < 256); // limit of dirent struct
5633 if (name[0] === '.') {
5634 id = 1;
5635 type = 4; // DT_DIR
5636 } else {
5637 var child = FS.lookupNode(stream.node, name);
5638 id = child.id;
5639 type = FS.isChrdev(child.mode) ? 2 : // DT_CHR, character device.
5640 FS.isDir(child.mode) ? 4 : // DT_DIR, directory.
5641 FS.isLink(child.mode) ? 10 : // DT_LNK, symbolic link.
5642 8; // DT_REG, regular file.
5643 }
5644 HEAP32[((dirp + pos)>>2)]=id;
5645 HEAP32[(((dirp + pos)+(4))>>2)]=stream.position;
5646 HEAP16[(((dirp + pos)+(8))>>1)]=268;
5647 HEAP8[(((dirp + pos)+(10))>>0)]=type;
5648 for (var i = 0; i < name.length; i++) {
5649 HEAP8[(((dirp + pos)+(11 + i))>>0)]=name.charCodeAt(i);
5650 }
5651 HEAP8[(((dirp + pos)+(11 + i))>>0)]=0;
5652 pos += 268;
5653 }
5654 return pos;
5655 } catch (e) {
5656 if (typeof FS === 'undefined' || !(e instanceof FS.ErrnoError)) abort(e);
5657 return -e.errno;
5658 }
5659 }
5660FS.staticInit();__ATINIT__.unshift(function() { if (!Module["noFSInit"] && !FS.init.initialized) FS.init() });__ATMAIN__.push(function() { FS.ignorePermissions = false });__ATEXIT__.push(function() { FS.quit() });Module["FS_createFolder"] = FS.createFolder;Module["FS_createPath"] = FS.createPath;Module["FS_createDataFile"] = FS.createDataFile;Module["FS_createPreloadedFile"] = FS.createPreloadedFile;Module["FS_createLazyFile"] = FS.createLazyFile;Module["FS_createLink"] = FS.createLink;Module["FS_createDevice"] = FS.createDevice;Module["FS_unlink"] = FS.unlink;
5661__ATINIT__.unshift(function() { TTY.init() });__ATEXIT__.push(function() { TTY.shutdown() });
5662if (ENVIRONMENT_IS_NODE) { var fs = require("fs"); var NODEJS_PATH = require("path"); NODEFS.staticInit(); }

Callers 1

_readdirFunction · 0.70

Calls 5

assertFunction · 0.70
abortFunction · 0.70
getMethod · 0.65
readdirMethod · 0.65
isDirMethod · 0.65

Tested by

no test coverage detected