Browse Source

Update README.md

wkh237 8 years ago
parent
commit
e4268ece8c
1 changed files with 46 additions and 8 deletions
  1. 46
    8
      README.md

+ 46
- 8
README.md View File

627
 
627
 
628
 ```js
628
 ```js
629
 RNFetchBlob.fs.mkdir(PATH_TO_CREATE)
629
 RNFetchBlob.fs.mkdir(PATH_TO_CREATE)
630
-.then(() => { ...})
631
-.catch((err) => { ...})
630
+.then(() => { ... })
631
+.catch((err) => { ... })
632
 ```
632
 ```
633
 
633
 
634
 #### ls(path:string):Promise<Array<String>>
634
 #### ls(path:string):Promise<Array<String>>
636
 List files and directories in a `path`
636
 List files and directories in a `path`
637
 
637
 
638
 ```js
638
 ```js
639
+RNFetchBlob.fs.ls(PATH_TO_LIST)
640
+    // files will an array contains filenames
641
+    .then((files) => {
642
+        console.log(files)
643
+    })
639
 ```
644
 ```
640
 
645
 
641
 #### mv(from:string, to:string):Promise
646
 #### mv(from:string, to:string):Promise
642
 
647
 
643
-TODO
648
+Move a file's location
649
+
650
+```js
651
+RNFetchBlob.fs.mv(FROM_PATH, TO_PATH)
652
+.then(() => { ... })
653
+.catch(() => { ... })
654
+```
644
 
655
 
645
-#### cp(path:string):Promise
656
+#### cp(src:string, dest:string):Promise
646
 
657
 
647
-TODO
658
+Copy a file.
659
+
660
+```js
661
+RNFetchBlob.fs.mv(SRC_PATH, DEST_PATH)
662
+.then(() => { ... })
663
+.catch(() => { ... })
664
+```
648
 
665
 
649
 #### exists(path:string):Promise<boolean>
666
 #### exists(path:string):Promise<boolean>
650
 
667
 
651
-TODO
668
+Check if a file exist at `path`
669
+
670
+```js
671
+RNFetchBlob.fs.exists(PATH_OF_FILE)
672
+.then((exist) => { 
673
+    console.log(`file ${exist ? '' : 'not'} exists`)
674
+})
675
+.catch(() => { ... })
676
+```
652
 
677
 
653
 #### isDir(path:string):Promise<boolean>
678
 #### isDir(path:string):Promise<boolean>
654
 
679
 
655
-TODO
680
+Check the file at `path` is a directory or not. Resolves with `false` when the path is not a directory, or it does not exists.
681
+
682
+```js
683
+RNFetchBlob.fs.exists(PATH_OF_FILE)
684
+.then((isDir) => { 
685
+    console.log(`file is ${isDir ? '' : 'not'} a directory`)
686
+})
687
+```
656
 
688
 
657
 #### unlink(path:string):Promise<boolean>
689
 #### unlink(path:string):Promise<boolean>
658
 
690
 
659
-TODO
691
+Delete a file at `path`
692
+
693
+```js
694
+RNFetchBlob.fs.unlink(path)
695
+.then(() => { ... })
696
+.catch((err) => { ... })
697
+```
660
 
698
 
661
 ### Types
699
 ### Types
662
 
700