Socket
Socket
Sign inDemoInstall

@ronomon/opened

Package Overview
Dependencies
14
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @ronomon/opened

Check if a file is open in another application on Windows, macOS and Linux.


Version published
Weekly downloads
110
increased by15.79%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

opened

Check if a file is open in another application on Windows, macOS and Linux. Linux requires privileges.

Installation

npm install @ronomon/opened

Windows

Opened uses a native binding on Windows to try and open an existing file with exclusive sharing mode (dwShareMode) and detect an ERROR_SHARING_VIOLATION error if another application already has an open handle to the file. This will detect any applications with open handles to the file, but not applications which have opened, buffered the file for display, and then closed the handle (i.e. applications which may be showing the file to the user, but which no longer have an open handle to the file).

Unix

Opened uses lsof on macOS and on Linux. On Linux (but not on macOS), lsof requires sudo permissions to iterate across open file descriptors for the user, otherwise no files will be detected as open and no permissions error will be returned.

Usage

var Opened = require('@ronomon/opened');
var paths = [...];
Opened.files(paths,
  function(error, hashTable) {
    if (error) throw error;
    paths.forEach(
      function(path) {
        console.log(path + ' open=' + hashTable[path]);
      }
    );
  }
);

Tests

node test.js

Keywords

FAQs

Last updated on 14 Apr 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc