You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+38-9Lines changed: 38 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
# FileSystem.js
2
-
FileSystem.js is a Promise-based wrapper library for the HTML5 FileSystem API. It smooths over the rough edges of the existing API and makes it simple to reason about its inherent asynchronicity. It uses native Promises since these have finally arrived in the stable version of Chrome.
2
+
FileSystem.js is a Promise-based wrapper library for the HTML5 FileSystem API. It smooths over the rough edges of the existing (FileSystem)[http://dev.w3.org/2009/dap/file-system/pub/FileSystem/] and (File)[http://dev.w3.org/2006/webapi/FileAPI/] APIs and makes it simple to reason about its inherent asynchronicity. It uses native Promises since these have finally arrived in the stable version of Chrome.
3
3
4
4
## Supported Browsers
5
5
- Chrome
@@ -14,34 +14,45 @@ By default, the minimum size (in bytes) will be 5Mb and the type will be persist
14
14
If you want to catch errors on the new filesystem object, it can be done as follows:
15
15
`fs.catch(onerrorfunction)`
16
16
17
-
## Examples
18
-
### Getting the root directory
17
+
### Examples
18
+
#### Getting the root directory
19
+
```javascript
19
20
fs.getRoot().then(function(root) {
20
21
// do something with the root directory
21
22
})
22
-
### Loading a url
23
+
```
24
+
#### Loading a filesystem url
25
+
```javascript
23
26
fs.getURL('[path]').then(function(entry) {
24
27
// do something with the directory or file
25
28
})
26
-
### Creating a directory
29
+
```
30
+
#### Creating a directory
31
+
```javascript
27
32
fs.getRoot().then(function(root) {
28
33
root.makeDirectory('somedir');
29
34
}).then(function(directory) {
30
35
// do something with the created directory
31
36
})
32
-
### Creating a file entry and writing to it in a directory
37
+
```
38
+
#### Creating a file entry and writing to it in a directory
39
+
```javascript
33
40
fs.getURL('/somedir').then(function(directory) {
34
41
returndirectory.makeFileEntry('somefile.txt');
35
42
}).then(function(fileEntry) {
36
43
fileEntry.write(newBlob(['who are you?'],{ type:'text/plaintext' }));
37
44
})
38
-
### Read all the files in a directory
45
+
```
46
+
#### Read all the files in a directory
47
+
```javascript
39
48
fs.getRoot().then(function(root) {
40
49
returnroot.readEntries();
41
50
}).then(function(entries) {
42
51
// do something with the entries which have just been read
43
52
})
44
-
### Read all of the ArrayBuffers for entries in a directory
53
+
```
54
+
#### Read all of the ArrayBuffers for entries in a directory
55
+
```javascript
45
56
fs.getRoot().then(function(root) {
46
57
returnroot.readEntries();
47
58
}).then(function(entries) {
@@ -54,4 +65,22 @@ If you want to catch errors on the new filesystem object, it can be done as foll
54
65
returnPromise.all(promises);
55
66
}).then(function(buffers) {
56
67
// do something with the array buffers
57
-
})
68
+
})
69
+
```
70
+
71
+
## API
72
+
### FileSystem
73
+
- new FileSystem(minimumSize, type)
74
+
- A promise-like object that wraps the local file system.
75
+
- **Parameters**:
76
+
- **minimumSize** - size in bytes for the browser file system
77
+
- **type** - either persistent(window.PERSISTENT == 1) or temporary(window.TEMPORARY == 0)
78
+
79
+
## License MIT
80
+
Copyright (c) 2014 Kirill Klimuk
81
+
82
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
83
+
84
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
85
+
86
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
0 commit comments