欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

node.js中的fs.lchmod方法使用說明

 更新時間:2014年12月16日 09:35:37   投稿:junjie  
這篇文章主要介紹了node.js中的fs.lchmod方法使用說明,本文介紹了fs.lchmod的方法說明、語法、接收參數(shù)、使用實例和實現(xiàn)源碼,需要的朋友可以參考下

方法說明:

更改文件權(quán)限(不解析符號鏈接)。

語法:

復(fù)制代碼 代碼如下:

fs.lchmod(fd, mode, [callback(err)])

由于該方法屬于fs模塊,使用前需要引入fs模塊(var fs= require(“fs”) )

接收參數(shù):

fd                文件描述符

mode          文件權(quán)限

callback      回調(diào),傳遞異常參數(shù)err

例子:

復(fù)制代碼 代碼如下:

fs.open('content.txt', 'a', function (err, fd) {
  if (err) {
    throw err;
  }
  fs.lchmod(fd, 0777, function(err){
 if (err) {
      throw err;
    }
 console.log('fchmod complete');
    fs.close(fd, function () {
      console.log('Done');
    });
  })
});

源碼:

復(fù)制代碼 代碼如下:

fs.lchmod = function(path, mode, callback) {
    callback = maybeCallback(callback);
    fs.open(path, constants.O_WRONLY | constants.O_SYMLINK, function(err, fd) {
      if (err) {
        callback(err);
        return;
      }
      // prefer to return the chmod error, if one occurs,
      // but still try to close, and report closing errors if they occur.
      fs.fchmod(fd, mode, function(err) {
        fs.close(fd, function(err2) {
          callback(err || err2);
        });
      });
    });
  };

相關(guān)文章

最新評論