wordpress   发布时间:2022-04-02  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了Windows上的节点文件模式?大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

在 Node中,文件模式(例如,对于 fs.open)被定义为 in the terms of the POSIX world(三位八进制值).但是,这并没有映射到Windows的工作方式. Windows在用户权限和文件系统之间没有这种紧密耦合. Windows’ OpenFile function甚至没有任何相关参数.但是从我到目前为止收集的内容来看,它们也没有完全被忽视. 有关如何在Wind
Node中,文件模式(例如,对于 fs.open)被定义为 in the terms of the POSIX world(三位八进制值).但是,这并没有映射到Windows的工作方式. Windows在用户权限和文件系统之间没有这种紧密耦合. Windows’ OpenFile function甚至没有任何相关参数.但是从我到目前为止收集的内容来看,它们也没有完全被忽视.

有关如何在Windows上使用节点文件模式的任何解释?

解决方法

看看 the source.看起来他们唯一要做的就是根据文件是否可写来设置FILE_ATTRIBUTE_READONLY.

if (flags & _O_CREAT) {
    if (!((req->mode & ~current_umask) & _S_IWRITE)) {
      attributes |= FILE_ATTRIBUTE_READONLY;
    }
  }

关于fs.chmod的注释也很有趣.

/* Todo: st_mode should probably always be 0666 for everyone. We might also
   * want to report 0777 if the file is a .exe or a directory.
   *
   * Currently it's based on whether the 'readonly' attribute is set,which
   * makes little sense because the semantics are so different: the 'read-only'
   * flag is just a way for a user to protect against accidental deleteion,and
   * serves no security purpose. Windows uses ACLs for that.
   *
   * Also people Now use uv_fs_chmod() to take away the writable bit for good
   * reasons. Windows however just makes the file read-only,which makes it
   * impossible to delete the file afterWARDs,since read-only files can't be
   * deleted.
   *
   * IOW it's all just a clusterfuck and we should think of something that
   * makes slighty more sense.
   *
   * And uv_fs_chmod should probably just fail on windows or be a @R_680_10586@l no-op.
   * There's nothing sensible it can do anyway.
   */

大佬总结

以上是大佬教程为你收集整理的Windows上的节点文件模式?全部内容,希望文章能够帮你解决Windows上的节点文件模式?所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。