Open a file handle exclusively and hold it, in order to other processes cannot access the file.
npm install native-file-monopolist
Or
yarn add native-file-monopolist
yarn configure
yarn build
yarn test
import { FileMonopolist } from 'native-file-monopolist';
const filePath = 'C:\\your-file-path';
const monopolist = new FileMonopolist(filePath);
console.log(monopolist.monopolized); // false
console.log(monopolist.filePath); // 'C:\\your-file-path'
const errorCode = monopolist.monopolize();
assert(errorCode === 0);
console.log(monopolist.monopolized); // true
const success = monopolist.dispose(); // true
console.log(monopolist.monopolized); // false
See index.d.ts
file for details.