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

Function ___syscall220

test/tests/emscripten/readdir.js:5665–5704  ·  view source on GitHub ↗
(which, varargs)

Source from the content-addressed store, hash-verified

5663 }
5664
5665 function ___syscall220(which, varargs) {SYSCALLS.varargs = varargs;
5666 try {
5667 // SYS_getdents64
5668 var stream = SYSCALLS.getStreamFromFD(), dirp = SYSCALLS.get(), count = SYSCALLS.get();
5669 if (!stream.getdents) {
5670 stream.getdents = FS.readdir(stream.path);
5671 }
5672 var pos = 0;
5673 while (stream.getdents.length > 0 && pos + 268 < count) {
5674 var id;
5675 var type;
5676 var name = stream.getdents.pop();
5677 assert(name.length < 256); // limit of dirent struct
5678 if (name[0] === '.') {
5679 id = 1;
5680 type = 4; // DT_DIR
5681 } else {
5682 var child = FS.lookupNode(stream.node, name);
5683 id = child.id;
5684 type = FS.isChrdev(child.mode) ? 2 : // DT_CHR, character device.
5685 FS.isDir(child.mode) ? 4 : // DT_DIR, directory.
5686 FS.isLink(child.mode) ? 10 : // DT_LNK, symbolic link.
5687 8; // DT_REG, regular file.
5688 }
5689 HEAP32[((dirp + pos)>>2)]=id;
5690 HEAP32[(((dirp + pos)+(4))>>2)]=stream.position;
5691 HEAP16[(((dirp + pos)+(8))>>1)]=268;
5692 HEAP8[(((dirp + pos)+(10))>>0)]=type;
5693 for (var i = 0; i < name.length; i++) {
5694 HEAP8[(((dirp + pos)+(11 + i))>>0)]=name.charCodeAt(i);
5695 }
5696 HEAP8[(((dirp + pos)+(11 + i))>>0)]=0;
5697 pos += 268;
5698 }
5699 return pos;
5700 } catch (e) {
5701 if (typeof FS === 'undefined' || !(e instanceof FS.ErrnoError)) abort(e);
5702 return -e.errno;
5703 }
5704 }
5705FS.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;
5706__ATINIT__.unshift(function() { TTY.init() });__ATEXIT__.push(function() { TTY.shutdown() });
5707if (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