@@ -38,10 +38,10 @@ public class ContentFilesystem extends Filesystem {
3838
3939 private final Context context ;
4040
41- public ContentFilesystem (Context context , CordovaResourceApi resourceApi , CordovaPreferences preferences ) {
42- super (Uri .parse ("content://" ), "content" , resourceApi , preferences );
41+ public ContentFilesystem (Context context , CordovaResourceApi resourceApi , CordovaPreferences preferences ) {
42+ super (Uri .parse ("content://" ), "content" , resourceApi , preferences );
4343 this .context = context ;
44- }
44+ }
4545
4646 @ Override
4747 public Uri toNativeUri (LocalFilesystemURL inputURL ) {
@@ -84,41 +84,41 @@ public LocalFilesystemURL toLocalUri(Uri inputURL) {
8484 }
8585
8686 @ Override
87- public JSONObject getFileForLocalURL (LocalFilesystemURL inputURL ,
88- String fileName , JSONObject options , boolean directory ) throws IOException , TypeMismatchException , JSONException {
87+ public JSONObject getFileForLocalURL (LocalFilesystemURL inputURL ,
88+ String fileName , JSONObject options , boolean directory ) throws IOException , TypeMismatchException , JSONException {
8989 throw new UnsupportedOperationException ("getFile() not supported for content:. Use resolveLocalFileSystemURL instead." );
90- }
90+ }
9191
92- @ Override
93- public boolean removeFileAtLocalURL (LocalFilesystemURL inputURL )
94- throws NoModificationAllowedException {
92+ @ Override
93+ public boolean removeFileAtLocalURL (LocalFilesystemURL inputURL )
94+ throws NoModificationAllowedException {
9595 Uri contentUri = toNativeUri (inputURL );
96- try {
96+ try {
9797 context .getContentResolver ().delete (contentUri , null , null );
98- } catch (UnsupportedOperationException t ) {
99- // Was seeing this on the File mobile-spec tests on 4.0.3 x86 emulator.
100- // The ContentResolver applies only when the file was registered in the
101- // first case, which is generally only the case with images.
98+ } catch (UnsupportedOperationException t ) {
99+ // Was seeing this on the File mobile-spec tests on 4.0.3 x86 emulator.
100+ // The ContentResolver applies only when the file was registered in the
101+ // first case, which is generally only the case with images.
102102 NoModificationAllowedException nmae = new NoModificationAllowedException ("Deleting not supported for content uri: " + contentUri );
103103 nmae .initCause (t );
104104 throw nmae ;
105- }
105+ }
106106 return true ;
107- }
107+ }
108108
109- @ Override
110- public boolean recursiveRemoveFileAtLocalURL (LocalFilesystemURL inputURL )
111- throws NoModificationAllowedException {
112- throw new NoModificationAllowedException ("Cannot remove content url" );
113- }
109+ @ Override
110+ public boolean recursiveRemoveFileAtLocalURL (LocalFilesystemURL inputURL )
111+ throws NoModificationAllowedException {
112+ throw new NoModificationAllowedException ("Cannot remove content url" );
113+ }
114114
115115 @ Override
116116 public LocalFilesystemURL [] listChildren (LocalFilesystemURL inputURL ) throws FileNotFoundException {
117117 throw new UnsupportedOperationException ("readEntriesAtLocalURL() not supported for content:. Use resolveLocalFileSystemURL instead." );
118118 }
119119
120- @ Override
121- public JSONObject getFileMetadataForLocalURL (LocalFilesystemURL inputURL ) throws FileNotFoundException {
120+ @ Override
121+ public JSONObject getFileMetadataForLocalURL (LocalFilesystemURL inputURL ) throws FileNotFoundException {
122122 long size = -1 ;
123123 long lastModified = 0 ;
124124 Uri nativeUri = toNativeUri (inputURL );
@@ -143,55 +143,55 @@ public JSONObject getFileMetadataForLocalURL(LocalFilesystemURL inputURL) throws
143143 fnfe .initCause (e );
144144 throw fnfe ;
145145 } finally {
146- if (cursor != null )
147- cursor .close ();
146+ if (cursor != null )
147+ cursor .close ();
148148 }
149149
150150 JSONObject metadata = new JSONObject ();
151151 try {
152- metadata .put ("size" , size );
153- metadata .put ("type" , mimeType );
154- metadata .put ("name" , name );
155- metadata .put ("fullPath" , inputURL .path );
156- metadata .put ("lastModifiedDate" , lastModified );
152+ metadata .put ("size" , size );
153+ metadata .put ("type" , mimeType );
154+ metadata .put ("name" , name );
155+ metadata .put ("fullPath" , inputURL .path );
156+ metadata .put ("lastModifiedDate" , lastModified );
157157 } catch (JSONException e ) {
158- return null ;
158+ return null ;
159159 }
160160 return metadata ;
161- }
161+ }
162162
163- @ Override
164- public long writeToFileAtURL (LocalFilesystemURL inputURL , String data ,
165- int offset , boolean isBinary ) throws NoModificationAllowedException {
163+ @ Override
164+ public long writeToFileAtURL (LocalFilesystemURL inputURL , String data ,
165+ int offset , boolean isBinary ) throws NoModificationAllowedException {
166166 throw new NoModificationAllowedException ("Couldn't write to file given its content URI" );
167167 }
168- @ Override
169- public long truncateFileAtURL (LocalFilesystemURL inputURL , long size )
170- throws NoModificationAllowedException {
168+ @ Override
169+ public long truncateFileAtURL (LocalFilesystemURL inputURL , long size )
170+ throws NoModificationAllowedException {
171171 throw new NoModificationAllowedException ("Couldn't truncate file given its content URI" );
172- }
172+ }
173173
174- protected Cursor openCursorForURL (Uri nativeUri ) {
174+ protected Cursor openCursorForURL (Uri nativeUri ) {
175175 ContentResolver contentResolver = context .getContentResolver ();
176176 try {
177177 return contentResolver .query (nativeUri , null , null , null , null );
178178 } catch (UnsupportedOperationException e ) {
179179 return null ;
180180 }
181- }
181+ }
182182
183- private Long resourceSizeForCursor (Cursor cursor ) {
183+ private Long resourceSizeForCursor (Cursor cursor ) {
184184 int columnIndex = cursor .getColumnIndex (OpenableColumns .SIZE );
185185 if (columnIndex != -1 ) {
186186 String sizeStr = cursor .getString (columnIndex );
187187 if (sizeStr != null ) {
188- return Long .parseLong (sizeStr );
188+ return Long .parseLong (sizeStr );
189189 }
190190 }
191191 return null ;
192- }
193-
194- protected Long lastModifiedDateForCursor (Cursor cursor ) {
192+ }
193+
194+ protected Long lastModifiedDateForCursor (Cursor cursor ) {
195195 int columnIndex = cursor .getColumnIndex (MediaStore .MediaColumns .DATE_MODIFIED );
196196 if (columnIndex == -1 ) {
197197 columnIndex = cursor .getColumnIndex (DocumentsContract .Document .COLUMN_LAST_MODIFIED );
@@ -203,22 +203,22 @@ protected Long lastModifiedDateForCursor(Cursor cursor) {
203203 }
204204 }
205205 return null ;
206- }
206+ }
207207
208208 @ Override
209209 public String filesystemPathForURL (LocalFilesystemURL url ) {
210210 File f = resourceApi .mapUriToFile (toNativeUri (url ));
211211 return f == null ? null : f .getAbsolutePath ();
212212 }
213213
214- @ Override
215- public LocalFilesystemURL URLforFilesystemPath (String path ) {
216- // Returns null as we don't support reverse mapping back to content:// URLs
217- return null ;
218- }
214+ @ Override
215+ public LocalFilesystemURL URLforFilesystemPath (String path ) {
216+ // Returns null as we don't support reverse mapping back to content:// URLs
217+ return null ;
218+ }
219219
220- @ Override
221- public boolean canRemoveFileAtLocalURL (LocalFilesystemURL inputURL ) {
222- return true ;
223- }
220+ @ Override
221+ public boolean canRemoveFileAtLocalURL (LocalFilesystemURL inputURL ) {
222+ return true ;
223+ }
224224}
0 commit comments