Skip to content

Akryum/winattr

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@akryum/winattr NPM Version Linux Build Windows Build Dependency Status

Foolproof Windows® file attributes for Node.js

Get and set:

  • archive
  • hidden
  • readonly
  • system

… on files and/or directories.

A native binding is used, offering great performance. As a contingency in case that fails, functionality will silently revert to a command line, though it is considerably slower.

Installation

It may go without saying, but this library is not intended to run on anything other than Windows.

Node.js >= 8 is required. To install, type this at the command line:

npm install @akryum/winattr

Or:

yarn add @akryum/winattr

Usage

get(path, callback)

path - Path to file or directory callback(err,attrs) - A callback which is called upon completion.

winattr.get('path/to/file.ext', (err, attrs) => {
  if (err == null) console.log(attrs)
})

If you omit the callback, a Promise will be return instead:

winattr.get('path/to/file.ext').then(attrs => {
  console.log(attrs)
})

getSync(path)

path - Path to file or directory

Returns an Object or throws an error if the file or dir cannot be found/accessed.

const attrs = winattr.getSync('path/to/file.ext')

console.log(attrs)

set(path, attrs, callback)

path - Path to file or directory attrs - An object containing attributes to change callback(err) - A callback which is called upon completion.

winattr.set('path/to/folder/', { readonly: true }, err => {
  if (err == null) console.log('success')
})

If you omit the callback, a Promise will be return instead:

winattr.set('path/to/folder/', { readonly: true }).then(() => {
  console.log('success')
})

setSync(path, attrs)

path - Path to file or directory attrs - An object containing attributes to change

Throws an error if the file or dir cannot be found/accessed.

winattr.setSync('path/to/folder/', { readonly: true })

About

📄 Foolproof Windows® file attributes.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy