3 ms·
I'm curious about the virtual filesystem: Welcome to PyPy.js! >>> import os >>> os.listdir('/') ['tmp', 'home', 'dev', 'lib'] >>> f = open('/what', '
by hathawsh 8y ago
I'm curious about the virtual filesystem:
Welcome to PyPy.js!
>>> import os
>>> os.listdir('/')
['tmp', 'home', 'dev', 'lib']
>>> f = open('/what', 'w')
>>> f.write('hey')
>>> f.close()
>>> os.listdir('/')
['tmp', 'home', 'dev', 'lib', 'what']
>>> open('/what').read()
'hey'
What is in the stack that makes that work?
- mattigames 8y agoThe Emscripten File System API, "The API is inspired by the Linux/POSIX File System API, with each presenting a very similar interface." https://kripken.github.io/emscripten-site/docs/api_reference/Filesystem-API.html https://kripken.github.io/emscripten-site/docs/api_reference...
- hathawsh 8y agoThanks!
- kjeetgill 8y agoI believe emscripten provides a virtual filesystem interface. Since it's essentially translating/running c it's either hooking through glibc or the syscall interfaces.
- deleted 8y ago[deleted]
- matmann2001 8y ago>>> import os >>> for root, dirs, files in os.walk('/'): ... for d in dirs: ... print os.path.join(root, d) + '/' ... for f in files: ... print os.path.join(root, f) ... /tmp/ /home/ /dev/ /lib/ /home/web_user/ /dev/shm/ /dev/null /dev/tty /dev/tty1 /dev/random /dev/urandom /dev/stdin /dev/stdout /dev/stderr /dev/shm/tmp/ /lib/pypyjs/ /lib/pypyjs/lib_pypy/ /lib/pypyjs/lib-python/ /lib/pypyjs/lib_pypy/encodings/ /lib/pypyjs/lib_pypy/UserDict.py /lib/pypyjs/lib_pypy/__future__.py /lib/pypyjs/lib_pypy/_abcoll.py /lib/pypyjs/lib_pypy/_structseq.py /lib/pypyjs/lib_pypy/_weakrefset.py /lib/pypyjs/lib_pypy/abc.py /lib/pypyjs/lib_pypy/base64.py /lib/pypyjs/lib_pypy/code.py /lib/pypyjs/lib_pypy/codecs.py /lib/pypyjs/lib_pypy/codeop.py /lib/pypyjs/lib_pypy/copy.py /lib/pypyjs/lib_pypy/copy_reg.py /lib/pypyjs/lib_pypy/genericpath.py /lib/pypyjs/lib_pypy/getopt.py /lib/pypyjs/lib_pypy/linecache.py /lib/pypyjs/lib_pypy/os.py /lib/pypyjs/lib_pypy/posixpath.py /lib/pypyjs/lib_pypy/pwd.py /lib/pypyjs/lib_pypy/re.py /lib/pypyjs/lib_pypy/repr.py /lib/pypyjs/lib_pypy/sre_compile.py /lib/pypyjs/lib_pypy/sre_constants.py /lib/pypyjs/lib_pypy/sre_parse.py /lib/pypyjs/lib_pypy/stat.py /lib/pypyjs/lib_pypy/struct.py /lib/pypyjs/lib_pypy/traceback.py /lib/pypyjs/lib_pypy/types.py /lib/pypyjs/lib_pypy/warnings.py /lib/pypyjs/lib_pypy/weakref.py /lib/pypyjs/lib_pypy/encodings/__init__.py /lib/pypyjs/lib_pypy/encodings/aliases.py /lib/pypyjs/lib_pypy/encodings/ascii.py /lib/pypyjs/lib_pypy/encodings/base64_codec.py /lib/pypyjs/lib_pypy/encodings/hex_codec.py /lib/pypyjs/lib_pypy/encodings/latin_1.py /lib/pypyjs/lib_pypy/encodings/raw_unicode_escape.py /lib/pypyjs/lib_pypy/encodings/string_escape.py /lib/pypyjs/lib_pypy/encodings/unicode_escape.py /lib/pypyjs/lib_pypy/encodings/unicode_internal.py /lib/pypyjs/lib_pypy/encodings/utf_16.py /lib/pypyjs/lib_pypy/encodings/utf_8.py /lib/pypyjs/lib-python/2.7/