Skip to content

feat: implement node fs #9811

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft

feat: implement node fs #9811

wants to merge 7 commits into from

Conversation

triniwiz
Copy link
Member

@triniwiz triniwiz commented Mar 6, 2022

Implements node fs API.

This could be split into a separate module so we can begin the splitting up the modules in core.

The core of this addition is written in rust.

  • Rust
Callback APIs implemented - [x] [fs.access(path[, mode], callback)](https://nodejs.org/api/fs.html#fsaccesspath-mode-callback) - [x] [fs.appendFile(path, data[, options], callback)](https://nodejs.org/api/fs.html#fsappendfilepath-data-options-callback) - [x] [fs.chmod(path, mode, callback)](https://nodejs.org/api/fs.html#fschmodpath-mode-callback) - [x] [fs.chown(path, uid, gid, callback)](https://nodejs.org/api/fs.html#fschownpath-uid-gid-callback) - [x] [fs.close(fd[, callback])](https://nodejs.org/api/fs.html#fsclosefd-callback) - [x] [fs.copyFile(src, dest[, mode], callback)](https://nodejs.org/api/fs.html#fscopyfilesrc-dest-mode-callback) - [x] [fs.cp(src, dest[, options], callback)](https://nodejs.org/api/fs.html#fscpsrc-dest-options-callback) - [ ] [fs.createReadStream(path[, options])](https://nodejs.org/api/fs.html#fscreatereadstreampath-options) - [ ] [fs.createWriteStream(path[, options])](https://nodejs.org/api/fs.html#fscreatewritestreampath-options) - [x] [fs.exists(path, callback)](https://nodejs.org/api/fs.html#fsexistspath-callback) - [x] [fs.fchmod(fd, mode, callback)](https://nodejs.org/api/fs.html#fsfchmodfd-mode-callback) - [x] [fs.fchown(fd, uid, gid, callback)](https://nodejs.org/api/fs.html#fsfchownfd-uid-gid-callback) - [x] [fs.fdatasync(fd, callback)](https://nodejs.org/api/fs.html#fsfdatasyncfd-callback) - [x] [fs.fstat(fd[, options], callback)](https://nodejs.org/api/fs.html#fsfstatfd-options-callback) - [x] [fs.fsync(fd, callback)](https://nodejs.org/api/fs.html#fsfsyncfd-callback) - [x] [fs.ftruncate(fd[, len], callback)](https://nodejs.org/api/fs.html#fsftruncatefd-len-callback) - [x] [fs.futimes(fd, atime, mtime, callback)](https://nodejs.org/api/fs.html#fsfutimesfd-atime-mtime-callback) - [x] [fs.lchmod(path, mode, callback)](https://nodejs.org/api/fs.html#fslchmodpath-mode-callback) - [x] [fs.lchown(path, uid, gid, callback)](https://nodejs.org/api/fs.html#fslchownpath-uid-gid-callback) - [x] [fs.lutimes(path, atime, mtime, callback)](https://nodejs.org/api/fs.html#fslutimespath-atime-mtime-callback) - [x] [fs.link(existingPath, newPath, callback)](https://nodejs.org/api/fs.html#fslinkexistingpath-newpath-callback) - [x] [fs.lstat(path[, options], callback)](https://nodejs.org/api/fs.html#fslstatpath-options-callback) - [x] [fs.mkdir(path[, options], callback)](https://nodejs.org/api/fs.html#fsmkdirpath-options-callback) - [x] [fs.mkdtemp(prefix[, options], callback)](https://nodejs.org/api/fs.html#fsmkdtempprefix-options-callback) - [x] [fs.open(path[, flags[, mode]], callback)](https://nodejs.org/api/fs.html#fsopenpath-flags-mode-callback) - [x] [fs.opendir(path[, options], callback)](https://nodejs.org/api/fs.html#fsopendirpath-options-callback) - [x] [fs.read(fd, buffer, offset, length, position, callback)](https://nodejs.org/api/fs.html#fsreadfd-buffer-offset-length-position-callback) - [x] [fs.read(fd, [options,] callback)](https://nodejs.org/api/fs.html#fsreadfd-options-callback) - [x] [fs.readdir(path[, options], callback)](https://nodejs.org/api/fs.html#fsreaddirpath-options-callback) - [x] [fs.readFile(path[, options], callback)](https://nodejs.org/api/fs.html#fsreadfilepath-options-callback) - [x] [fs.readlink(path[, options], callback)](https://nodejs.org/api/fs.html#fsreadlinkpath-options-callback) - [x] [fs.readv(fd, buffers[, position], callback)](https://nodejs.org/api/fs.html#fsreadvfd-buffers-position-callback) - [x] [fs.realpath(path[, options], callback)](https://nodejs.org/api/fs.html#fsrealpathpath-options-callback) - [x] [fs.realpath.native(path[, options], callback)](https://nodejs.org/api/fs.html#fsrealpathnativepath-options-callback) - [x] [fs.rename(oldPath, newPath, callback)](https://nodejs.org/api/fs.html#fsrenameoldpath-newpath-callback) - [x] [fs.rmdir(path[, options], callback)](https://nodejs.org/api/fs.html#fsrmdirpath-options-callback) - [x] [fs.rm(path[, options], callback)](https://nodejs.org/api/fs.html#fsrmpath-options-callback) - [x] [fs.stat(path[, options], callback)](https://nodejs.org/api/fs.html#fsstatpath-options-callback) - [x] [fs.symlink(target, path[, type], callback)](https://nodejs.org/api/fs.html#fssymlinktarget-path-type-callback) - [x] [fs.truncate(path[, len], callback)](https://nodejs.org/api/fs.html#fstruncatepath-len-callback) - [x] [fs.unlink(path, callback)](https://nodejs.org/api/fs.html#fsunlinkpath-callback) - [x] [fs.unwatchFile(filename[, listener])](https://nodejs.org/api/fs.html#fsunwatchfilefilename-listener) - [x] [fs.utimes(path, atime, mtime, callback)](https://nodejs.org/api/fs.html#fsutimespath-atime-mtime-callback) - [x] [fs.watch(filename[, options][, listener])](https://nodejs.org/api/fs.html#fswatchfilename-options-listener) - [x] [fs.watchFile(filename[, options], listener)](https://nodejs.org/api/fs.html#fswatchfilefilename-options-listener) - [x] [fs.write(fd, buffer[, offset[, length[, position]]], callback)](https://nodejs.org/api/fs.html#fswritefd-buffer-offset-length-position-callback) - [x] [fs.write(fd, string[, position[, encoding]], callback)](https://nodejs.org/api/fs.html#fswritefd-string-position-encoding-callback) - [x] [fs.writeFile(file, data[, options], callback)](https://nodejs.org/api/fs.html#fswritefilefile-data-options-callback) - [x] [fs.writev(fd, buffers[, position], callback)](https://nodejs.org/api/fs.html#fswritevfd-buffers-position-callback)
Sync APIs implemented - [x] [fs.accessSync(path[, mode])](https://nodejs.org/api/fs.html#fsaccesssyncpath-mode) - [x] [fs.appendFileSync(path, data[, options])](https://nodejs.org/api/fs.html#fsappendfilesyncpath-data-options) - [x] [fs.chmodSync(path, mode)](https://nodejs.org/api/fs.html#fschmodsyncpath-mode) - [x] [fs.chownSync(path, uid, gid)](https://nodejs.org/api/fs.html#fschownsyncpath-uid-gid) - [x] [fs.closeSync(fd)](https://nodejs.org/api/fs.html#fsclosesyncfd) - [x] [fs.copyFileSync(src, dest[, mode])](https://nodejs.org/api/fs.html#fscopyfilesyncsrc-dest-mode) - [x] [fs.cpSync(src, dest[, options])](https://nodejs.org/api/fs.html#fscpsyncsrc-dest-options) - [x] [fs.existsSync(path)](https://nodejs.org/api/fs.html#fsexistssyncpath) - [x] [fs.fchmodSync(fd, mode)](https://nodejs.org/api/fs.html#fsfchmodsyncfd-mode) - [x] [fs.fchownSync(fd, uid, gid)](https://nodejs.org/api/fs.html#fsfchownsyncfd-uid-gid) - [x] [fs.fdatasyncSync(fd)](https://nodejs.org/api/fs.html#fsfdatasyncsyncfd) - [x] [fs.fstatSync(fd[, options])](https://nodejs.org/api/fs.html#fsfstatsyncfd-options) - [x] [fs.fsyncSync(fd)](https://nodejs.org/api/fs.html#fsfsyncsyncfd) - [x] [fs.ftruncateSync(fd[, len])](https://nodejs.org/api/fs.html#fsftruncatesyncfd-len) - [x] [fs.futimesSync(fd, atime, mtime)](https://nodejs.org/api/fs.html#fsfutimessyncfd-atime-mtime) - [x] [fs.lchmodSync(path, mode)](https://nodejs.org/api/fs.html#fslchmodsyncpath-mode) - [x] [fs.lchownSync(path, uid, gid)](https://nodejs.org/api/fs.html#fslchownsyncpath-uid-gid) - [x] [fs.lutimesSync(path, atime, mtime)](https://nodejs.org/api/fs.html#fslutimessyncpath-atime-mtime) - [x] [fs.linkSync(existingPath, newPath)](https://nodejs.org/api/fs.html#fslinksyncexistingpath-newpath) - [x] [fs.lstatSync(path[, options])](https://nodejs.org/api/fs.html#fslstatsyncpath-options) - [x] [fs.mkdirSync(path[, options])](https://nodejs.org/api/fs.html#fsmkdirsyncpath-options) - [x] [fs.mkdtempSync(prefix[, options])](https://nodejs.org/api/fs.html#fsmkdtempsyncprefix-options) - [x] [fs.opendirSync(path[, options])](https://nodejs.org/api/fs.html#fsopendirsyncpath-options) - [x] [fs.openSync(path[, flags[, mode]])](https://nodejs.org/api/fs.html#fsopensyncpath-flags-mode) - [x] [fs.readdirSync(path[, options])](https://nodejs.org/api/fs.html#fsreaddirsyncpath-options) - [x] [fs.readFileSync(path[, options])](https://nodejs.org/api/fs.html#fsreadfilesyncpath-options) - [x] [fs.readlinkSync(path[, options])](https://nodejs.org/api/fs.html#fsreadlinksyncpath-options) - [x] [fs.readSync(fd, buffer, offset, length, position)](https://nodejs.org/api/fs.html#fsreadsyncfd-buffer-offset-length-position) - [x] [fs.readSync(fd, buffer[, options])](https://nodejs.org/api/fs.html#fsreadsyncfd-buffer-options) - [x] [fs.readvSync(fd, buffers[, position])](https://nodejs.org/api/fs.html#fsreadvsyncfd-buffers-position) - [x] [fs.realpathSync(path[, options])](https://nodejs.org/api/fs.html#fsrealpathsyncpath-options) - [x] [fs.realpathSync.native(path[, options])](https://nodejs.org/api/fs.html#fsrealpathsyncnativepath-options) - [x] [fs.renameSync(oldPath, newPath)](https://nodejs.org/api/fs.html#fsrenamesyncoldpath-newpath) - [x] [fs.rmdirSync(path[, options])](https://nodejs.org/api/fs.html#fsrmdirsyncpath-options) - [x] [fs.rmSync(path[, options])](https://nodejs.org/api/fs.html#fsrmsyncpath-options) - [x] [fs.statSync(path[, options])](https://nodejs.org/api/fs.html#fsstatsyncpath-options) - [x] [fs.symlinkSync(target, path[, type])](https://nodejs.org/api/fs.html#fssymlinksynctarget-path-type) - [x] [fs.truncateSync(path[, len])](https://nodejs.org/api/fs.html#fstruncatesyncpath-len) - [x] [fs.unlinkSync(path)](https://nodejs.org/api/fs.html#fsunlinksyncpath) - [x] [fs.utimesSync(path, atime, mtime)](https://nodejs.org/api/fs.html#fsutimessyncpath-atime-mtime) - [x] [fs.writeFileSync(file, data[, options])](https://nodejs.org/api/fs.html#fswritefilesyncfile-data-options) - [x] [fs.writeSync(fd, buffer[, offset[, length[, position]]])](https://nodejs.org/api/fs.html#fswritesyncfd-buffer-offset-length-position) - [x] [fs.writeSync(fd, string[, position[, encoding]])](https://nodejs.org/api/fs.html#fswritesyncfd-string-position-encoding) - [x] [fs.writevSync(fd, buffers[, position])](https://nodejs.org/api/fs.html#fswritevsyncfd-buffers-position)
  • Android
  • IOS
  • Core/Module

#195

@cla-bot cla-bot bot added the cla: yes label Mar 6, 2022
@NathanWalker NathanWalker added this to the 8.3 milestone Mar 10, 2022
@NathanWalker NathanWalker modified the milestones: 8.3, 9.0 Jul 13, 2022
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those const exports seems not that pretty and not even really necessary. from the js side onlyrw... seems necessary. Wouldnt it be best to move all that to native? Like pass the rw... flags to native and handle all that there. Would remove the need for all those consts in the JS side

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants