@@ -106,7 +106,7 @@ public JSONObject makeEntryForFile(File file) {
106
106
}
107
107
108
108
abstract JSONObject getFileForLocalURL (LocalFilesystemURL inputURL , String path ,
109
- JSONObject options , boolean directory ) throws FileExistsException , IOException , TypeMismatchException , EncodingException , JSONException ;
109
+ JSONObject options , boolean directory ) throws FileExistsException , IOException , TypeMismatchException , EncodingException , JSONException ;
110
110
111
111
abstract boolean removeFileAtLocalURL (LocalFilesystemURL inputURL ) throws InvalidModificationException , NoModificationAllowedException ;
112
112
@@ -174,13 +174,13 @@ protected static String normalizePath(String rawPath) {
174
174
if (components .get (index ).equals (".." )) {
175
175
components .remove (index );
176
176
if (index > 0 ) {
177
- components .remove (index - 1 );
177
+ components .remove (index - 1 );
178
178
--index ;
179
179
}
180
180
}
181
181
}
182
182
StringBuilder normalizedPath = new StringBuilder ();
183
- for (String component : components ) {
183
+ for (String component : components ) {
184
184
normalizedPath .append ("/" );
185
185
normalizedPath .append (component );
186
186
}
@@ -200,6 +200,7 @@ public long getFreeSpaceInBytes() {
200
200
}
201
201
202
202
public abstract Uri toNativeUri (LocalFilesystemURL inputURL );
203
+
203
204
public abstract LocalFilesystemURL toLocalUri (Uri inputURL );
204
205
205
206
public JSONObject getRootEntry () {
@@ -221,7 +222,7 @@ public JSONObject getParentForLocalURL(LocalFilesystemURL inputURL) throws IOExc
221
222
protected LocalFilesystemURL makeDestinationURL (String newName , LocalFilesystemURL srcURL , LocalFilesystemURL destURL , boolean isDirectory ) {
222
223
// I know this looks weird but it is to work around a JSON bug.
223
224
if ("null" .equals (newName ) || "" .equals (newName )) {
224
- newName = srcURL .uri .getLastPathSegment ();;
225
+ newName = srcURL .uri .getLastPathSegment ();
225
226
}
226
227
227
228
String newDest = destURL .uri .toString ();
@@ -242,7 +243,7 @@ protected LocalFilesystemURL makeDestinationURL(String newName, LocalFilesystemU
242
243
* or remove the source file when finished.
243
244
*/
244
245
public JSONObject copyFileToURL (LocalFilesystemURL destURL , String newName ,
245
- Filesystem srcFs , LocalFilesystemURL srcURL , boolean move ) throws IOException , InvalidModificationException , JSONException , NoModificationAllowedException , FileExistsException {
246
+ Filesystem srcFs , LocalFilesystemURL srcURL , boolean move ) throws IOException , InvalidModificationException , JSONException , NoModificationAllowedException , FileExistsException {
246
247
// First, check to see that we can do it
247
248
if (move && !srcFs .canRemoveFileAtLocalURL (srcURL )) {
248
249
throw new NoModificationAllowedException ("Cannot move file at source URL" );
@@ -294,7 +295,7 @@ public void readFileAtURL(LocalFilesystemURL inputURL, long start, long end,
294
295
}
295
296
296
297
abstract long writeToFileAtURL (LocalFilesystemURL inputURL , String data , int offset ,
297
- boolean isBinary ) throws NoModificationAllowedException , IOException ;
298
+ boolean isBinary ) throws NoModificationAllowedException , IOException ;
298
299
299
300
abstract long truncateFileAtURL (LocalFilesystemURL inputURL , long size )
300
301
throws IOException , NoModificationAllowedException ;
@@ -308,10 +309,12 @@ abstract long truncateFileAtURL(LocalFilesystemURL inputURL, long size)
308
309
309
310
protected class LimitedInputStream extends FilterInputStream {
310
311
long numBytesToRead ;
312
+
311
313
public LimitedInputStream (InputStream in , long numBytesToRead ) {
312
314
super (in );
313
315
this .numBytesToRead = numBytesToRead ;
314
316
}
317
+
315
318
@ Override
316
319
public int read () throws IOException {
317
320
if (numBytesToRead <= 0 ) {
@@ -320,14 +323,15 @@ public int read() throws IOException {
320
323
numBytesToRead --;
321
324
return in .read ();
322
325
}
326
+
323
327
@ Override
324
328
public int read (byte [] buffer , int byteOffset , int byteCount ) throws IOException {
325
329
if (numBytesToRead <= 0 ) {
326
330
return -1 ;
327
331
}
328
332
int bytesToRead = byteCount ;
329
333
if (byteCount > numBytesToRead ) {
330
- bytesToRead = (int )numBytesToRead ; // Cast okay; long is less than int here.
334
+ bytesToRead = (int ) numBytesToRead ; // Cast okay; long is less than int here.
331
335
}
332
336
int numBytesRead = in .read (buffer , byteOffset , bytesToRead );
333
337
numBytesToRead -= numBytesRead ;
@@ -341,8 +345,8 @@ protected Uri.Builder createLocalUriBuilder() {
341
345
String path = LocalFilesystemURL .fsNameToCdvKeyword (name );
342
346
343
347
return new Uri .Builder ()
344
- .scheme (scheme )
345
- .authority (hostname )
346
- .path (path );
348
+ .scheme (scheme )
349
+ .authority (hostname )
350
+ .path (path );
347
351
}
348
352
}
0 commit comments