hidefile
Version:
Hide files and directories on all platforms.
135 lines (106 loc) • 4.04 kB
Markdown
> Hide files and directories on all platforms.
Unix:
* Adds or removes a "." prefix on a file or dir
Windows:
* Adds or removes a "." prefix on a file or dir
* Adds or removes the "hidden" attribute on a file or dir
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.
[](http://nodejs.org/) `>= 8` is required. To install, type this at the command line:
```
npm install hidefile
```
`path` - Path to file or directory
`callback(err,newpath)` - A callback which is called upon completion
```js
hidefile.hide('path/to/file.ext', (err, newpath) => {
if (err == null) {
console.log(newpath); //-> 'path/to/.file.ext'
}
});
```
`path` - Path to file or directory
Throws an error if the file or dir cannot be found/accessed.
```js
const newpath = hidefile.hideSync('path/to/file.ext');
console.log(newpath); //-> 'path/to/.file.ext'
```
`path` - Path to file or directory
```js
console.log( hidefile.isDotPrefixed('path/to/.file.ext') ); //-> true
console.log( hidefile.isDotPrefixed('path/to/file.ext') ); //-> false
```
`path` - Path to file or directory
`callback(result)` - A callback which is called upon completion
```js
hidefile.isHidden('path/to/file.ext', (err, result) => {
if (err == null) {
console.log(result); //-> false
}
});
```
Unix: `result` is `true` if prefixed.
Windows: `result` is `true` if prefixed *and* has "hidden" attribute, `false` if only prefixed.
`path` - Path to file or directory
Throws an error if the file or dir cannot be found/accessed.
```js
const result = hidefile.isHiddenSync('path/to/file.ext');
console.log(result); //-> false
```
`path` - Path to file or directory
`callback(err,newpath)` - A callback which is called upon completion
```js
hidefile.reveal('path/to/.file.ext', (err, newpath) => {
if (err == null) {
console.log(newpath); //-> 'path/to/file.ext'
}
});
```
`path` - Path to file or directory
Throws an error if the file or dir cannot be found/accessed.
```js
const newpath = hidefile.revealSync('path/to/.file.ext');
console.log(newpath); //-> 'path/to/file.ext'
```
`path` - Path to file or directory
`callback(result)` - A callback which is called upon completion
```js
if (isWindows) {
hidefile.shouldBeHidden('path/to/.file.ext', (err, result) => {
if (err == null) {
console.log(result); //-> true
}
});
}
```
Unix: `result` is `true` if prefixed.
Windows: `result` is `true` if prefixed *or* has "hidden" attribute.
`path` - Path to file or directory
Throws an error if the file or dir cannot be found/accessed.
```js
if (isWindows) {
result = hidefile.shouldBeHiddenSync('path/to/.file.ext');
console.log(result); //-> true
}
```
[]: https://img.shields.io/npm/v/hidefile.svg
[]: https://npmjs.com/package/hidefile
[]: https://img.shields.io/travis/stevenvachon/hidefile.svg?label=linux
[]: https://travis-ci.org/stevenvachon/hidefile
[]: https://img.shields.io/appveyor/ci/stevenvachon/hidefile.svg?label=windows
[]: https://ci.appveyor.com/project/stevenvachon/hidefile
[]: https://img.shields.io/coveralls/stevenvachon/hidefile.svg
[]: https://coveralls.io/github/stevenvachon/hidefile
[]: https://badges.greenkeeper.io/stevenvachon/hidefile.svg
[]: https://greenkeeper.io/