Skip to content

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

License

Notifications You must be signed in to change notification settings

DingpingZhang/native-file-monopolist

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published