0.3.0 • Published 4 years ago

native-file-monopolist v0.3.0

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

Native File Monopolist

Open a file handle exclusively and hold it, in order to other processes cannot access the file.

Install

npm install native-file-monopolist

Or

yarn add native-file-monopolist

Build

yarn configure
yarn build

Test

yarn test

Use

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

API

See index.d.ts file for details.