方法說明
用來建立硬鏈接(hard link)。硬鏈接會讓兩個路徑指向同一份 inode 資料,刪除其中一個名稱並不會真正移除資料。
語法
fs.link(srcpath, dstpath, [callback(err)])
此方式屬於 fs 模組,使用前必須先引入:var fs = require("fs")
參數說明
srcpath:來源目錄或檔案的路徑。
dstpath:存放鏈接的路徑,預設為目前工作目錄。
callback:回調函式,接收 err 異常參數。
原始碼
fs.link = function(srcpath, dstpath, callback) {
callback = makeCallback(callback);
if (!nullCheck(srcpath, callback)) return;
if (!nullCheck(dstpath, callback)) return;
binding.link(pathModule._makeLong(srcpath),
pathModule._makeLong(dstpath),
callback);
};