winattr !NPM Versionnpm-imagenpm-url !Linux Buildtravis-imagetravis-url !Windows Buildappveyor-imageappveyor-url !Dependency Statusdavid-imagedavid-url
Foolproof Windows® file attributes for Node.jsGet and set:
archive
hidden
readonly
system
Installation
It may go without saying, but this library is not intended to run on anything other than Windows. Node.js>= 4
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
```js
winattr.get("path/to/file.ext", function(err, attrs) {
if (err == null) console.log(attrs);
});
```
If you omit the callback, a Promise will be return instead.
getSync(path)
path
- Path to file or directory
Returns an Object
or throws an error if the file or dir cannot be found/accessed.
```js
var 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
```js
winattr.set("path/to/folder/", {readonly:true}, function(err) {
if (err == null) console.log("success");
});
```
If you omit the callback, a Promise will be return instead.
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.
```js
winattr.setSync("path/to/folder/", {readonly:true});
```