@aminya/winattr
v4.0.3
Published
Promisified - Foolproof Windows® file attributes.
Downloads
24
Maintainers
Readme
winattr
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 winattr
Methods
get(path: string): Promise<Attributes>
path
- Path to file or directory
const attrs = await winattr.get('path/to/file.ext')
console.log(attrs)
getSync(path: string): Attributes
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: string, attrs: Attributes): Promise<void>
path
- Path to file or directoryattrs
- An object containing attributes to change
await winattr.set('path/to/folder/', {readonly:true})
setSync(path, attrs)
path
- Path to file or directoryattrs
- 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});
Attributes
type:
interface Attributes {
archive: boolean
hidden: boolean
readonly: boolean
system: boolean
}