fcf.NLock.isLockFile() function
[SERVER ONLY]
fcf.NLock.isLockFile (string a_filePath, function a_cb)
[SERVER ONLY]
fcf.NLock.isLockFile (number a_fileHandle, function a_cb)
Package: fcf-framework-lock
File: fcf-framework-lock:index.js
Available from version: 1.0.0
Checks if a file is locked.
Arguments
- The path to a file.
- The open file handle returned by the FS.open() function
- The function of processing the result of the function execution.
Function signature: a_cb(
-
Error |undefined a_error - Error object. -
boolean a_isLocked -true if the file has a lock.
Example: Function application
let libUtil = require("util");
let libLock = require("fcf-framework-lock");
async function main(){
if (await libUtil.promisify(libLock .isLockFile )("index.js")){
console.log("File is locked");
} else {
console.log("File is not locked");
}
let lock = await libUtil.promisify(libLock .lockFile )("index.js");
if (await libUtil.promisify(libLock .isLockFile )("index.js")){
console.log("File is locked");
} else {
console.log("File is not locked");
}
await libUtil.promisify(libLock .unlockFile )(lock);
}
main();
Output:
File is not locked
File is locked