Advanced APIs#

This section lists APIs that are not suitable for general use, but which may be useful to developers in some circumstances. These include APIs that are difficult or complicated to use, or which are intended primarily for developers working on the Emscripten core.

preamble.js#

The following advanced APIs are documented in preamble.js.

allocate(slab, allocator)#

This is marked as internal because it is difficult to use (it has been optimized for multiple syntaxes to save space in generated code). Normally developers should instead allocate memory using _malloc(), initialize it with setValue(), etc., but this function may be useful for advanced developers in certain cases.

Arguments:
  • slab – An array of data, or a number. If a number, then the size of the block to allocate, in bytes.

  • allocator – How to allocate memory, see ALLOC_*

Advanced File System API#

File System API covers the public API that will be relevant to most developers. The following functions are only needed for advanced use-cases (for example, writing a new local file system) or legacy file system compatibility.

FS.hashName(parentid, name)#
FS.hashAddNode(node)#
FS.hashRemoveNode(node)#
FS.lookupNode(parent, name)#
FS.createNode(parent, name, mode, rdev)#
FS.destroyNode(node)#
FS.isRoot(node)#
FS.isMountpoint(node)#
FS.isFIFO(node)#
FS.nextfd()#
FS.getStream(fd)#
FS.createStream(stream, fd)#
FS.closeStream(fd)#
FS.getStreamFromPtr(ptr)#
FS.getPtrForStream(stream)#
FS.major(dev)#
FS.minor(dev)#
FS.getDevice(dev)#
FS.getMounts(mount)#
FS.lookup(parent, name)#
FS.mknod(path, mode, dev)#
FS.create(path, mode)#
FS.mmap(stream, buffer, offset, length, position, prot, flags)#
FS.ioctl(stream, cmd, arg)#
FS.staticInit()#
FS.quit()#
FS.indexedDB()#
FS.DB_NAME()#

For advanced users only.

FS.getMode(canRead, canWrite)#
FS.createPath(parent, path, canRead, canWrite)#
FS.createFile(parent, name, properties, canRead, canWrite)#
FS.createDataFile(parent, name, data, canRead, canWrite, canOwn)#
FS.createDevice(parent, name, input, output)#
FS.forceLoadFile(obj)#

Legacy functions.

FS.analyzePath(path, dontResolveLastLink)#

There are also a small number of additional flag modes:

  • rs

  • xw

  • xw+

  • xa

  • xa+