這篇文章主要介紹了node.js中的fs.symlinkSync方法使用說明,本文介紹了fs.symlinkSync的方法說明、語法、接收參數(shù)、使用實例和實現(xiàn)源碼,需要的朋友可以參考下
方法說明:
同步版的 symlink() 。用于創(chuàng)建符號鏈接。
語法:
復(fù)制代碼代碼如下:
fs.symlinkSync(srcpath, dstpath, [type])
由于該方法屬于fs模塊,使用前需要引入fs模塊(var fs= require(“fs”) )
接收參數(shù):
srcpath 為源目錄或文件的路徑
dstpath 它是存放轉(zhuǎn)換后的目錄的路徑,默認為當(dāng)前工作目錄
type 默認值:'file' , 可選值 ‘dir', ‘file', 或者 ‘junction' ,該項僅用于Windows(在其他平臺上忽略)。
注意Windows結(jié)點需要轉(zhuǎn)換后的目錄是絕對路徑,使用“junction”時,目標參數(shù)將自動被歸一化到的絕對路徑。
源碼:
復(fù)制代碼代碼如下:
fs.symlinkSync = function(destination, path, type) {
type = (util.isString(type) ? type : null);
nullCheck(destination);
nullCheck(path);
return binding.symlink(preprocessSymlinkDestination(destination, type),
pathModule._makeLong(path),
type);
};