Skip to content

Commit

Permalink
Task: Update docs for file locking
Browse files Browse the repository at this point in the history
  • Loading branch information
nick spragg committed Jan 30, 2017
1 parent cdf7f36 commit f204279
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,17 @@ npm install --save file-js
## Features

* File glob matching
* File matching with regular expressions
* Supports promises and callbacks
* File listings
* File locking
* Assert file permissions
* Supports promises
* Supports synchronous and asynchronous methods

## Coming soon

* File matching with regular expressions
* Support for callbacks

## Demo

<img src="" width="600"/>
Expand Down Expand Up @@ -72,6 +79,21 @@ const dir = File.create('myDirectory');
dir.getFiles().each(console.log);
```

#### File locking

Perform operations on a file whilst locked:
```js
const fs = require('fs');
const file = File.create('myFile');

file.withLock(() => {
file.isWritable((w_ok) => {
if (w_ok) {
fs.writeFileSync(file.getAbsolutePath(), 'my data\n');
}
});
});
```
#### Check permissions

Check that a pathname has write permission:
Expand Down

0 comments on commit f204279

Please sign in to comment.