|
@@ -300,7 +300,25 @@ function exists(path:string):Promise<bool, bool> {
|
300
|
300
|
}
|
301
|
301
|
|
302
|
302
|
function slice(src:string, dest:string, start:number, end:number):Promise {
|
303
|
|
- return RNFetchBlob.slice(src, dest, start, end)
|
|
303
|
+ let p = Promise.resolve()
|
|
304
|
+ let size = 0
|
|
305
|
+ function normalize(num, size) {
|
|
306
|
+ if(num < 0)
|
|
307
|
+ return Math.max(0, size + num)
|
|
308
|
+ if(!num && num !== 0)
|
|
309
|
+ return size
|
|
310
|
+ return num
|
|
311
|
+ }
|
|
312
|
+ if(start < 0 || end < 0 || !start || !end) {
|
|
313
|
+ p = p.then(() => stat(src))
|
|
314
|
+ .then((stat) => {
|
|
315
|
+ size = Math.floor(stat.size)
|
|
316
|
+ start = normalize(start || 0, size)
|
|
317
|
+ end = normalize(end, size)
|
|
318
|
+ return Promise.resolve()
|
|
319
|
+ })
|
|
320
|
+ }
|
|
321
|
+ return p.then(() => RNFetchBlob.slice(src, dest, start, end))
|
304
|
322
|
}
|
305
|
323
|
|
306
|
324
|
function isDir(path:string):Promise<bool, bool> {
|