You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ia...@apache.org on 2014/04/25 20:13:53 UTC
[7/8] CB-6521: Remove development branch
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/9976b306/src/android/FileUtils.java
----------------------------------------------------------------------
diff --git a/src/android/FileUtils.java b/src/android/FileUtils.java
deleted file mode 100644
index a7e86fa..0000000
--- a/src/android/FileUtils.java
+++ /dev/null
@@ -1,986 +0,0 @@
-/*
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
- */
-package org.apache.cordova.file;
-
-import android.app.Activity;
-import android.content.Context;
-import android.net.Uri;
-import android.os.Environment;
-import android.util.Base64;
-import android.util.Log;
-
-import org.apache.cordova.CallbackContext;
-import org.apache.cordova.CordovaInterface;
-import org.apache.cordova.CordovaPlugin;
-import org.apache.cordova.CordovaWebView;
-import org.apache.cordova.PluginResult;
-
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URLDecoder;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-
-/**
- * This class provides file and directory services to JavaScript.
- */
-public class FileUtils extends CordovaPlugin {
- private static final String LOG_TAG = "FileUtils";
-
- public static int NOT_FOUND_ERR = 1;
- public static int SECURITY_ERR = 2;
- public static int ABORT_ERR = 3;
-
- public static int NOT_READABLE_ERR = 4;
- public static int ENCODING_ERR = 5;
- public static int NO_MODIFICATION_ALLOWED_ERR = 6;
- public static int INVALID_STATE_ERR = 7;
- public static int SYNTAX_ERR = 8;
- public static int INVALID_MODIFICATION_ERR = 9;
- public static int QUOTA_EXCEEDED_ERR = 10;
- public static int TYPE_MISMATCH_ERR = 11;
- public static int PATH_EXISTS_ERR = 12;
-
- public static int UNKNOWN_ERR = 1000;
-
- private boolean configured = false;
-
- // This field exists only to support getEntry, below, which has been deprecated
- private static FileUtils filePlugin;
-
- private interface FileOp {
- void run( ) throws Exception;
- }
-
- private ArrayList<Filesystem> filesystems;
-
- public void registerFilesystem(Filesystem fs) {
- if (fs != null && filesystemForName(fs.name)== null) {
- this.filesystems.add(fs);
- }
- }
-
- private Filesystem filesystemForName(String name) {
- for (Filesystem fs:filesystems) {
- if (fs != null && fs.name != null && fs.name.equals(name)) {
- return fs;
- }
- }
- return null;
- }
-
- protected String[] getExtraFileSystemsPreference(Activity activity) {
- String fileSystemsStr = activity.getIntent().getStringExtra("androidextrafilesystems");
- if (fileSystemsStr == null) {
- fileSystemsStr = "files,files-external,documents,sdcard,cache,cache-external,root";
- }
- return fileSystemsStr.split(",");
- }
-
- protected void registerExtraFileSystems(String[] filesystems, HashMap<String, String> availableFileSystems) {
- HashSet<String> installedFileSystems = new HashSet<String>();
-
- /* Register filesystems in order */
- for (String fsName : filesystems) {
- if (!installedFileSystems.contains(fsName)) {
- String fsRoot = availableFileSystems.get(fsName);
- if (fsRoot != null) {
- File newRoot = new File(fsRoot);
- if (newRoot.mkdirs() || newRoot.isDirectory()) {
- registerFilesystem(new LocalFilesystem(fsName, cordova, fsRoot));
- installedFileSystems.add(fsName);
- } else {
- Log.d(LOG_TAG, "Unable to create root dir for fileystem \"" + fsName + "\", skipping");
- }
- } else {
- Log.d(LOG_TAG, "Unrecognized extra filesystem identifier: " + fsName);
- }
- }
- }
- }
-
- protected HashMap<String, String> getAvailableFileSystems(Activity activity) {
- Context context = activity.getApplicationContext();
- HashMap<String, String> availableFileSystems = new HashMap<String,String>();
-
- availableFileSystems.put("files", context.getFilesDir().getAbsolutePath());
- availableFileSystems.put("files-external", context.getExternalFilesDir(null).getAbsolutePath());
- availableFileSystems.put("documents", new File(context.getFilesDir(), "Documents").getAbsolutePath());
- availableFileSystems.put("sdcard", Environment.getExternalStorageDirectory().getAbsolutePath());
- availableFileSystems.put("cache", context.getCacheDir().getAbsolutePath());
- availableFileSystems.put("cache-external", context.getExternalCacheDir().getAbsolutePath());
- availableFileSystems.put("root", "/");
-
- return availableFileSystems;
- }
-
- @Override
- public void initialize(CordovaInterface cordova, CordovaWebView webView) {
- super.initialize(cordova, webView);
- this.filesystems = new ArrayList<Filesystem>();
-
- String tempRoot = null;
- String persistentRoot = null;
-
- Activity activity = cordova.getActivity();
- String packageName = activity.getPackageName();
-
- String location = activity.getIntent().getStringExtra("androidpersistentfilelocation");
- if (location == null) {
- location = "compatibility";
- }
- tempRoot = activity.getCacheDir().getAbsolutePath();
- if ("internal".equalsIgnoreCase(location)) {
- persistentRoot = activity.getFilesDir().getAbsolutePath() + "/files/";
- this.configured = true;
- } else if ("compatibility".equalsIgnoreCase(location)) {
- /*
- * Fall-back to compatibility mode -- this is the logic implemented in
- * earlier versions of this plugin, and should be maintained here so
- * that apps which were originally deployed with older versions of the
- * plugin can continue to provide access to files stored under those
- * versions.
- */
- if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
- persistentRoot = Environment.getExternalStorageDirectory().getAbsolutePath();
- tempRoot = Environment.getExternalStorageDirectory().getAbsolutePath() +
- "/Android/data/" + packageName + "/cache/";
- } else {
- persistentRoot = "/data/data/" + packageName;
- }
- this.configured = true;
- }
-
- if (this.configured) {
- // Create the directories if they don't exist.
- new File(tempRoot).mkdirs();
- new File(persistentRoot).mkdirs();
-
- // Register initial filesystems
- // Note: The temporary and persistent filesystems need to be the first two
- // registered, so that they will match window.TEMPORARY and window.PERSISTENT,
- // per spec.
- this.registerFilesystem(new LocalFilesystem("temporary", cordova, tempRoot));
- this.registerFilesystem(new LocalFilesystem("persistent", cordova, persistentRoot));
- this.registerFilesystem(new ContentFilesystem("content", cordova, webView));
-
- registerExtraFileSystems(getExtraFileSystemsPreference(activity), getAvailableFileSystems(activity));
-
- // Initialize static plugin reference for deprecated getEntry method
- if (filePlugin == null) {
- FileUtils.filePlugin = this;
- }
- } else {
- Log.e(LOG_TAG, "File plugin configuration error: Please set AndroidPersistentFileLocation in config.xml to one of \"internal\" (for new applications) or \"compatibility\" (for compatibility with previous versions)");
- activity.finish();
- }
- }
-
- public static FileUtils getFilePlugin() {
- return filePlugin;
- }
-
- private Filesystem filesystemForURL(LocalFilesystemURL localURL) {
- if (localURL == null) return null;
- return filesystemForName(localURL.filesystemName);
- }
-
- @Override
- public Uri remapUri(Uri uri) {
- try {
- LocalFilesystemURL inputURL = new LocalFilesystemURL(uri);
- Filesystem fs = this.filesystemForURL(inputURL);
- if (fs == null) {
- return null;
- }
- String path = fs.filesystemPathForURL(inputURL);
- if (path != null) {
- return Uri.parse("file:///" + fs.filesystemPathForURL(inputURL));
- }
- return null;
- } catch (IllegalArgumentException e) {
- return null;
- }
- }
-
- /**
- * Executes the request and returns whether the action was valid.
- *
- * @param action The action to execute.
- * @param args JSONArray of arguments for the plugin.
- * @param callbackContext The callback context used when calling back into JavaScript.
- * @return True if the action was valid, false otherwise.
- */
- public boolean execute(String action, final JSONArray args, final CallbackContext callbackContext) throws JSONException {
- if (!configured) {
- callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.ERROR, "File plugin is not configured. Please see the README.md file for details on how to update config.xml"));
- return true;
- }
- if (action.equals("testSaveLocationExists")) {
- threadhelper( new FileOp( ){
- public void run() {
- boolean b = DirectoryManager.testSaveLocationExists();
- callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, b));
- }
- },callbackContext);
- }
- else if (action.equals("getFreeDiskSpace")) {
- threadhelper( new FileOp( ){
- public void run() {
- long l = DirectoryManager.getFreeDiskSpace(false);
- callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, l));
- }
- },callbackContext);
- }
- else if (action.equals("testFileExists")) {
- final String fname=args.getString(0);
- threadhelper( new FileOp( ){
- public void run() {
- boolean b = DirectoryManager.testFileExists(fname);
- callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, b));
- }
- }, callbackContext);
- }
- else if (action.equals("testDirectoryExists")) {
- final String fname=args.getString(0);
- threadhelper( new FileOp( ){
- public void run() {
- boolean b = DirectoryManager.testFileExists(fname);
- callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, b));
- }
- }, callbackContext);
- }
- else if (action.equals("readAsText")) {
- final String encoding = args.getString(1);
- final int start = args.getInt(2);
- final int end = args.getInt(3);
- final String fname=args.getString(0);
- threadhelper( new FileOp( ){
- public void run() throws MalformedURLException {
- readFileAs(fname, start, end, callbackContext, encoding, PluginResult.MESSAGE_TYPE_STRING);
- }
- }, callbackContext);
- }
- else if (action.equals("readAsDataURL")) {
- final int start = args.getInt(1);
- final int end = args.getInt(2);
- final String fname=args.getString(0);
- threadhelper( new FileOp( ){
- public void run() throws MalformedURLException {
- readFileAs(fname, start, end, callbackContext, null, -1);
- }
- }, callbackContext);
- }
- else if (action.equals("readAsArrayBuffer")) {
- final int start = args.getInt(1);
- final int end = args.getInt(2);
- final String fname=args.getString(0);
- threadhelper( new FileOp( ){
- public void run() throws MalformedURLException {
- readFileAs(fname, start, end, callbackContext, null, PluginResult.MESSAGE_TYPE_ARRAYBUFFER);
- }
- },callbackContext);
- }
- else if (action.equals("readAsBinaryString")) {
- final int start = args.getInt(1);
- final int end = args.getInt(2);
- final String fname=args.getString(0);
- threadhelper( new FileOp( ){
- public void run() throws MalformedURLException {
- readFileAs(fname, start, end, callbackContext, null, PluginResult.MESSAGE_TYPE_BINARYSTRING);
- }
- }, callbackContext);
- }
- else if (action.equals("write")) {
- final String fname=args.getString(0);
- final String data=args.getString(1);
- final int offset=args.getInt(2);
- final Boolean isBinary=args.getBoolean(3);
- threadhelper( new FileOp( ){
- public void run() throws FileNotFoundException, IOException, NoModificationAllowedException {
- long fileSize = write(fname, data, offset, isBinary);
- callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, fileSize));
- }
- }, callbackContext);
- }
- else if (action.equals("truncate")) {
- final String fname=args.getString(0);
- final int offset=args.getInt(1);
- threadhelper( new FileOp( ){
- public void run( ) throws FileNotFoundException, IOException, NoModificationAllowedException {
- long fileSize = truncateFile(fname, offset);
- callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, fileSize));
- }
- }, callbackContext);
- }
- else if (action.equals("requestFileSystem")) {
- final int fstype=args.getInt(0);
- final long size = args.optLong(1);
- threadhelper( new FileOp( ){
- public void run() throws IOException, JSONException {
- if (size != 0 && size > (DirectoryManager.getFreeDiskSpace(true) * 1024)) {
- callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.ERROR, FileUtils.QUOTA_EXCEEDED_ERR));
- } else {
- JSONObject obj = requestFileSystem(fstype);
- callbackContext.success(obj);
- }
- }
- }, callbackContext);
- }
- else if (action.equals("resolveLocalFileSystemURI")) {
- final String fname=args.getString(0);
- threadhelper( new FileOp( ){
- public void run() throws IOException, JSONException {
- JSONObject obj = resolveLocalFileSystemURI(fname);
- callbackContext.success(obj);
- }
- },callbackContext);
- }
- else if (action.equals("getMetadata") || action.equals("getFileMetadata")) {
- final String fname=args.getString(0);
- threadhelper( new FileOp( ){
- public void run() throws FileNotFoundException, JSONException, MalformedURLException {
- JSONObject obj = getFileMetadata(fname);
- callbackContext.success(obj);
- }
- }, callbackContext);
- }
- else if (action.equals("getParent")) {
- final String fname=args.getString(0);
- threadhelper( new FileOp( ){
- public void run() throws JSONException, IOException {
- JSONObject obj = getParent(fname);
- callbackContext.success(obj);
- }
- },callbackContext);
- }
- else if (action.equals("getDirectory")) {
- final String dirname=args.getString(0);
- final String path=args.getString(1);
- threadhelper( new FileOp( ){
- public void run() throws FileExistsException, IOException, TypeMismatchException, EncodingException, JSONException {
- JSONObject obj = getFile(dirname, path, args.optJSONObject(2), true);
- callbackContext.success(obj);
- }
- },callbackContext);
- }
- else if (action.equals("getFile")) {
- final String dirname=args.getString(0);
- final String path=args.getString(1);
- threadhelper( new FileOp( ){
- public void run() throws FileExistsException, IOException, TypeMismatchException, EncodingException, JSONException {
- JSONObject obj = getFile(dirname, path, args.optJSONObject(2), false);
- callbackContext.success(obj);
- }
- },callbackContext);
- }
- else if (action.equals("remove")) {
- final String fname=args.getString(0);
- threadhelper( new FileOp( ){
- public void run() throws NoModificationAllowedException, InvalidModificationException, MalformedURLException {
- boolean success = remove(fname);
- if (success) {
- callbackContext.success();
- } else {
- callbackContext.error(FileUtils.NO_MODIFICATION_ALLOWED_ERR);
- }
- }
- },callbackContext);
- }
- else if (action.equals("removeRecursively")) {
- final String fname=args.getString(0);
- threadhelper( new FileOp( ){
- public void run() throws FileExistsException, MalformedURLException, NoModificationAllowedException {
- boolean success = removeRecursively(fname);
- if (success) {
- callbackContext.success();
- } else {
- callbackContext.error(FileUtils.NO_MODIFICATION_ALLOWED_ERR);
- }
- }
- },callbackContext);
- }
- else if (action.equals("moveTo")) {
- final String fname=args.getString(0);
- final String newParent=args.getString(1);
- final String newName=args.getString(2);
- threadhelper( new FileOp( ){
- public void run() throws JSONException, NoModificationAllowedException, IOException, InvalidModificationException, EncodingException, FileExistsException {
- JSONObject entry = transferTo(fname, newParent, newName, true);
- callbackContext.success(entry);
- }
- },callbackContext);
- }
- else if (action.equals("copyTo")) {
- final String fname=args.getString(0);
- final String newParent=args.getString(1);
- final String newName=args.getString(2);
- threadhelper( new FileOp( ){
- public void run() throws JSONException, NoModificationAllowedException, IOException, InvalidModificationException, EncodingException, FileExistsException {
- JSONObject entry = transferTo(fname, newParent, newName, false);
- callbackContext.success(entry);
- }
- },callbackContext);
- }
- else if (action.equals("readEntries")) {
- final String fname=args.getString(0);
- threadhelper( new FileOp( ){
- public void run() throws FileNotFoundException, JSONException, MalformedURLException {
- JSONArray entries = readEntries(fname);
- callbackContext.success(entries);
- }
- },callbackContext);
- }
- else if (action.equals("_getLocalFilesystemPath")) {
- // Internal method for testing: Get the on-disk location of a local filesystem url.
- // [Currently used for testing file-transfer]
- final String localURLstr = args.getString(0);
- threadhelper( new FileOp( ){
- public void run() throws FileNotFoundException, JSONException, MalformedURLException {
- String fname = filesystemPathForURL(localURLstr);
- callbackContext.success(fname);
- }
- },callbackContext);
- }
- else {
- return false;
- }
- return true;
- }
-
- /*
- * These two native-only methods can be used by other plugins to translate between
- * device file system paths and URLs. By design, there is no direct JavaScript
- * interface to these methods.
- */
-
- public String filesystemPathForURL(String localURLstr) throws MalformedURLException {
- try {
- LocalFilesystemURL inputURL = new LocalFilesystemURL(localURLstr);
- Filesystem fs = this.filesystemForURL(inputURL);
- if (fs == null) {
- throw new MalformedURLException("No installed handlers for this URL");
- }
- return fs.filesystemPathForURL(inputURL);
- } catch (IllegalArgumentException e) {
- throw new MalformedURLException("Unrecognized filesystem URL");
- }
- }
-
- public LocalFilesystemURL filesystemURLforLocalPath(String localPath) {
- LocalFilesystemURL localURL = null;
- int shortestFullPath = 0;
-
- // Try all installed filesystems. Return the best matching URL
- // (determined by the shortest resulting URL)
- for (Filesystem fs: filesystems) {
- if (fs != null) {
- LocalFilesystemURL url = fs.URLforFilesystemPath(localPath);
- if (url != null) {
- // A shorter fullPath implies that the filesystem is a better
- // match for the local path than the previous best.
- if (localURL == null || (url.fullPath.length() < shortestFullPath)) {
- localURL = url;
- shortestFullPath = url.fullPath.length();
- }
- }
- }
- }
- return localURL;
- }
-
-
- /* helper to execute functions async and handle the result codes
- *
- */
- private void threadhelper(final FileOp f, final CallbackContext callbackContext){
- cordova.getThreadPool().execute(new Runnable() {
- public void run() {
- try {
- f.run();
- } catch ( Exception e) {
- e.printStackTrace();
- if( e instanceof EncodingException){
- callbackContext.error(FileUtils.ENCODING_ERR);
- } else if(e instanceof FileNotFoundException) {
- callbackContext.error(FileUtils.NOT_FOUND_ERR);
- } else if(e instanceof FileExistsException) {
- callbackContext.error(FileUtils.PATH_EXISTS_ERR);
- } else if(e instanceof NoModificationAllowedException ) {
- callbackContext.error(FileUtils.NO_MODIFICATION_ALLOWED_ERR);
- } else if(e instanceof InvalidModificationException ) {
- callbackContext.error(FileUtils.INVALID_MODIFICATION_ERR);
- } else if(e instanceof MalformedURLException ) {
- callbackContext.error(FileUtils.ENCODING_ERR);
- } else if(e instanceof IOException ) {
- callbackContext.error(FileUtils.INVALID_MODIFICATION_ERR);
- } else if(e instanceof EncodingException ) {
- callbackContext.error(FileUtils.ENCODING_ERR);
- } else if(e instanceof TypeMismatchException ) {
- callbackContext.error(FileUtils.TYPE_MISMATCH_ERR);
- } else {
- callbackContext.error(FileUtils.UNKNOWN_ERR);
- }
- }
- }
- });
- }
-
- /**
- * Allows the user to look up the Entry for a file or directory referred to by a local URI.
- *
- * @param url of the file/directory to look up
- * @return a JSONObject representing a Entry from the filesystem
- * @throws MalformedURLException if the url is not valid
- * @throws FileNotFoundException if the file does not exist
- * @throws IOException if the user can't read the file
- * @throws JSONException
- */
- private JSONObject resolveLocalFileSystemURI(String url) throws IOException, JSONException {
- LocalFilesystemURL inputURL;
- if (url == null) {
- throw new MalformedURLException("Unrecognized filesystem URL");
- }
-
- /* Backwards-compatibility: Check for file:// urls */
- if (url.startsWith("file:/")) {
- if (!url.startsWith("file://")) {
- url = "file:///" + url.substring(6);
- }
- String decoded = URLDecoder.decode(url, "UTF-8");
- /* This looks like a file url. Get the path, and see if any handlers recognize it. */
- String path;
- int questionMark = decoded.indexOf("?");
- int pathEnd;
- if (questionMark < 0) {
- pathEnd = decoded.length();
- } else {
- pathEnd = questionMark;
- }
-
- int thirdSlash = decoded.indexOf("/", 7);
- if (thirdSlash < 0 || thirdSlash > pathEnd) {
- path = "";
- } else {
- path = decoded.substring(thirdSlash, pathEnd);
- }
- inputURL = this.filesystemURLforLocalPath(path);
- } else {
- inputURL = new LocalFilesystemURL(url);
- }
-
- try {
- Filesystem fs = this.filesystemForURL(inputURL);
- if (fs == null) {
- throw new MalformedURLException("No installed handlers for this URL");
- }
- return fs.getEntryForLocalURL(inputURL);
- } catch (IllegalArgumentException e) {
- throw new MalformedURLException("Unrecognized filesystem URL");
- }
- }
-
- /**
- * Read the list of files from this directory.
- *
- * @param fileName the directory to read from
- * @return a JSONArray containing JSONObjects that represent Entry objects.
- * @throws FileNotFoundException if the directory is not found.
- * @throws JSONException
- * @throws MalformedURLException
- */
- private JSONArray readEntries(String baseURLstr) throws FileNotFoundException, JSONException, MalformedURLException {
- try {
- LocalFilesystemURL inputURL = new LocalFilesystemURL(baseURLstr);
- Filesystem fs = this.filesystemForURL(inputURL);
- if (fs == null) {
- throw new MalformedURLException("No installed handlers for this URL");
- }
- return fs.readEntriesAtLocalURL(inputURL);
-
- } catch (IllegalArgumentException e) {
- throw new MalformedURLException("Unrecognized filesystem URL");
- }
- }
-
- /**
- * A setup method that handles the move/copy of files/directories
- *
- * @param fileName to be copied/moved
- * @param newParent is the location where the file will be copied/moved to
- * @param newName for the file directory to be called, if null use existing file name
- * @param move if false do a copy, if true do a move
- * @return a Entry object
- * @throws NoModificationAllowedException
- * @throws IOException
- * @throws InvalidModificationException
- * @throws EncodingException
- * @throws JSONException
- * @throws FileExistsException
- */
- private JSONObject transferTo(String srcURLstr, String destURLstr, String newName, boolean move) throws JSONException, NoModificationAllowedException, IOException, InvalidModificationException, EncodingException, FileExistsException {
- if (srcURLstr == null || destURLstr == null) {
- // either no source or no destination provided
- throw new FileNotFoundException();
- }
-
- LocalFilesystemURL srcURL = new LocalFilesystemURL(srcURLstr);
- LocalFilesystemURL destURL = new LocalFilesystemURL(destURLstr);
-
- Filesystem srcFs = this.filesystemForURL(srcURL);
- Filesystem destFs = this.filesystemForURL(destURL);
-
- // Check for invalid file name
- if (newName != null && newName.contains(":")) {
- throw new EncodingException("Bad file name");
- }
-
- return destFs.copyFileToURL(destURL, newName, srcFs, srcURL, move);
- }
-
- /**
- * Deletes a directory and all of its contents, if any. In the event of an error
- * [e.g. trying to delete a directory that contains a file that cannot be removed],
- * some of the contents of the directory may be deleted.
- * It is an error to attempt to delete the root directory of a filesystem.
- *
- * @param filePath the directory to be removed
- * @return a boolean representing success of failure
- * @throws FileExistsException
- * @throws NoModificationAllowedException
- * @throws MalformedURLException
- */
- private boolean removeRecursively(String baseURLstr) throws FileExistsException, NoModificationAllowedException, MalformedURLException {
- try {
- LocalFilesystemURL inputURL = new LocalFilesystemURL(baseURLstr);
- // You can't delete the root directory.
- if ("".equals(inputURL.fullPath) || "/".equals(inputURL.fullPath)) {
- throw new NoModificationAllowedException("You can't delete the root directory");
- }
-
- Filesystem fs = this.filesystemForURL(inputURL);
- if (fs == null) {
- throw new MalformedURLException("No installed handlers for this URL");
- }
- return fs.recursiveRemoveFileAtLocalURL(inputURL);
-
- } catch (IllegalArgumentException e) {
- throw new MalformedURLException("Unrecognized filesystem URL");
- }
- }
-
-
- /**
- * Deletes a file or directory. It is an error to attempt to delete a directory that is not empty.
- * It is an error to attempt to delete the root directory of a filesystem.
- *
- * @param filePath file or directory to be removed
- * @return a boolean representing success of failure
- * @throws NoModificationAllowedException
- * @throws InvalidModificationException
- * @throws MalformedURLException
- */
- private boolean remove(String baseURLstr) throws NoModificationAllowedException, InvalidModificationException, MalformedURLException {
- try {
- LocalFilesystemURL inputURL = new LocalFilesystemURL(baseURLstr);
- // You can't delete the root directory.
- if ("".equals(inputURL.fullPath) || "/".equals(inputURL.fullPath)) {
-
- throw new NoModificationAllowedException("You can't delete the root directory");
- }
-
- Filesystem fs = this.filesystemForURL(inputURL);
- if (fs == null) {
- throw new MalformedURLException("No installed handlers for this URL");
- }
- return fs.removeFileAtLocalURL(inputURL);
-
- } catch (IllegalArgumentException e) {
- throw new MalformedURLException("Unrecognized filesystem URL");
- }
- }
-
- /**
- * Creates or looks up a file.
- *
- * @param baseURLstr base directory
- * @param path file/directory to lookup or create
- * @param options specify whether to create or not
- * @param directory if true look up directory, if false look up file
- * @return a Entry object
- * @throws FileExistsException
- * @throws IOException
- * @throws TypeMismatchException
- * @throws EncodingException
- * @throws JSONException
- */
- private JSONObject getFile(String baseURLstr, String path, JSONObject options, boolean directory) throws FileExistsException, IOException, TypeMismatchException, EncodingException, JSONException {
- try {
- LocalFilesystemURL inputURL = new LocalFilesystemURL(baseURLstr);
- Filesystem fs = this.filesystemForURL(inputURL);
- if (fs == null) {
- throw new MalformedURLException("No installed handlers for this URL");
- }
- return fs.getFileForLocalURL(inputURL, path, options, directory);
-
- } catch (IllegalArgumentException e) {
- throw new MalformedURLException("Unrecognized filesystem URL");
- }
-
- }
-
- /**
- * Look up the parent DirectoryEntry containing this Entry.
- * If this Entry is the root of its filesystem, its parent is itself.
- *
- * @param filePath
- * @return
- * @throws JSONException
- * @throws IOException
- */
- private JSONObject getParent(String baseURLstr) throws JSONException, IOException {
- try {
- LocalFilesystemURL inputURL = new LocalFilesystemURL(baseURLstr);
- Filesystem fs = this.filesystemForURL(inputURL);
- if (fs == null) {
- throw new MalformedURLException("No installed handlers for this URL");
- }
- return fs.getParentForLocalURL(inputURL);
-
- } catch (IllegalArgumentException e) {
- throw new MalformedURLException("Unrecognized filesystem URL");
- }
- }
-
- /**
- * Returns a File that represents the current state of the file that this FileEntry represents.
- *
- * @param filePath to entry
- * @return returns a JSONObject represent a W3C File object
- * @throws FileNotFoundException
- * @throws JSONException
- * @throws MalformedURLException
- */
- private JSONObject getFileMetadata(String baseURLstr) throws FileNotFoundException, JSONException, MalformedURLException {
- try {
- LocalFilesystemURL inputURL = new LocalFilesystemURL(baseURLstr);
- Filesystem fs = this.filesystemForURL(inputURL);
- if (fs == null) {
- throw new MalformedURLException("No installed handlers for this URL");
- }
- return fs.getFileMetadataForLocalURL(inputURL);
-
- } catch (IllegalArgumentException e) {
- throw new MalformedURLException("Unrecognized filesystem URL");
- }
- }
-
- /**
- * Requests a filesystem in which to store application data.
- *
- * @param type of file system requested
- * @return a JSONObject representing the file system
- * @throws IOException
- * @throws JSONException
- */
- private JSONObject requestFileSystem(int type) throws IOException, JSONException {
- JSONObject fs = new JSONObject();
- Filesystem rootFs = null;
- try {
- rootFs = this.filesystems.get(type);
- } catch (ArrayIndexOutOfBoundsException e) {
- // Pass null through
- }
- if (rootFs == null) {
- throw new IOException("No filesystem of type requested");
- }
- fs.put("name", rootFs.name);
- fs.put("root", Filesystem.makeEntryForPath("/", rootFs.name, true));
- return fs;
- }
-
- /**
- * Returns a JSON object representing the given File. Internal APIs should be modified
- * to use URLs instead of raw FS paths wherever possible, when interfacing with this plugin.
- *
- * @param file the File to convert
- * @return a JSON representation of the given File
- * @throws JSONException
- */
- public JSONObject getEntryForFile(File file) throws JSONException {
- JSONObject entry;
-
- for (Filesystem fs : filesystems) {
- entry = fs.makeEntryForFile(file);
- if (entry != null) {
- return entry;
- }
- }
- return null;
- }
-
- /**
- * Returns a JSON object representing the given File. Deprecated, as this is only used by
- * FileTransfer, and because it is a static method that should really be an instance method,
- * since it depends on the actual filesystem roots in use. Internal APIs should be modified
- * to use URLs instead of raw FS paths wherever possible, when interfacing with this plugin.
- *
- * @param file the File to convert
- * @return a JSON representation of the given File
- * @throws JSONException
- */
- @Deprecated
- public static JSONObject getEntry(File file) throws JSONException {
- if (getFilePlugin() != null) {
- return getFilePlugin().getEntryForFile(file);
- }
- return null;
- }
-
- /**
- * Read the contents of a file.
- * This is done in a background thread; the result is sent to the callback.
- *
- * @param filename The name of the file.
- * @param start Start position in the file.
- * @param end End position to stop at (exclusive).
- * @param callbackContext The context through which to send the result.
- * @param encoding The encoding to return contents as. Typical value is UTF-8. (see http://www.iana.org/assignments/character-sets)
- * @param resultType The desired type of data to send to the callback.
- * @return Contents of file.
- * @throws MalformedURLException
- */
- public void readFileAs(final String srcURLstr, final int start, final int end, final CallbackContext callbackContext, final String encoding, final int resultType) throws MalformedURLException {
- try {
- LocalFilesystemURL inputURL = new LocalFilesystemURL(srcURLstr);
- Filesystem fs = this.filesystemForURL(inputURL);
- if (fs == null) {
- throw new MalformedURLException("No installed handlers for this URL");
- }
-
- fs.readFileAtURL(inputURL, start, end, new Filesystem.ReadFileCallback() {
- public void handleData(InputStream inputStream, String contentType) {
- try {
- ByteArrayOutputStream os = new ByteArrayOutputStream();
- final int BUFFER_SIZE = 8192;
- byte[] buffer = new byte[BUFFER_SIZE];
-
- for (;;) {
- int bytesRead = inputStream.read(buffer, 0, BUFFER_SIZE);
-
- if (bytesRead <= 0) {
- break;
- }
- os.write(buffer, 0, bytesRead);
- }
-
- PluginResult result;
- switch (resultType) {
- case PluginResult.MESSAGE_TYPE_STRING:
- result = new PluginResult(PluginResult.Status.OK, os.toString(encoding));
- break;
- case PluginResult.MESSAGE_TYPE_ARRAYBUFFER:
- result = new PluginResult(PluginResult.Status.OK, os.toByteArray());
- break;
- case PluginResult.MESSAGE_TYPE_BINARYSTRING:
- result = new PluginResult(PluginResult.Status.OK, os.toByteArray(), true);
- break;
- default: // Base64.
- byte[] base64 = Base64.encode(os.toByteArray(), Base64.NO_WRAP);
- String s = "data:" + contentType + ";base64," + new String(base64, "US-ASCII");
- result = new PluginResult(PluginResult.Status.OK, s);
- }
-
- callbackContext.sendPluginResult(result);
- } catch (IOException e) {
- Log.d(LOG_TAG, e.getLocalizedMessage());
- callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.IO_EXCEPTION, NOT_READABLE_ERR));
- }
- }
- });
-
-
- } catch (IllegalArgumentException e) {
- throw new MalformedURLException("Unrecognized filesystem URL");
- } catch (FileNotFoundException e) {
- callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.IO_EXCEPTION, NOT_FOUND_ERR));
- } catch (IOException e) {
- Log.d(LOG_TAG, e.getLocalizedMessage());
- callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.IO_EXCEPTION, NOT_READABLE_ERR));
- }
- }
-
-
- /**
- * Write contents of file.
- *
- * @param filename The name of the file.
- * @param data The contents of the file.
- * @param offset The position to begin writing the file.
- * @param isBinary True if the file contents are base64-encoded binary data
- * @throws FileNotFoundException, IOException
- * @throws NoModificationAllowedException
- */
- /**/
- public long write(String srcURLstr, String data, int offset, boolean isBinary) throws FileNotFoundException, IOException, NoModificationAllowedException {
- try {
- LocalFilesystemURL inputURL = new LocalFilesystemURL(srcURLstr);
- Filesystem fs = this.filesystemForURL(inputURL);
- if (fs == null) {
- throw new MalformedURLException("No installed handlers for this URL");
- }
-
- long x = fs.writeToFileAtURL(inputURL, data, offset, isBinary); Log.d("TEST",srcURLstr + ": "+x); return x;
- } catch (IllegalArgumentException e) {
- throw new MalformedURLException("Unrecognized filesystem URL");
- }
-
- }
-
- /**
- * Truncate the file to size
- *
- * @param filename
- * @param size
- * @throws FileNotFoundException, IOException
- * @throws NoModificationAllowedException
- */
- private long truncateFile(String srcURLstr, long size) throws FileNotFoundException, IOException, NoModificationAllowedException {
- try {
- LocalFilesystemURL inputURL = new LocalFilesystemURL(srcURLstr);
- Filesystem fs = this.filesystemForURL(inputURL);
- if (fs == null) {
- throw new MalformedURLException("No installed handlers for this URL");
- }
-
- return fs.truncateFileAtURL(inputURL, size);
- } catch (IllegalArgumentException e) {
- throw new MalformedURLException("Unrecognized filesystem URL");
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/9976b306/src/android/Filesystem.java
----------------------------------------------------------------------
diff --git a/src/android/Filesystem.java b/src/android/Filesystem.java
deleted file mode 100644
index 954c098..0000000
--- a/src/android/Filesystem.java
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
- */
-package org.apache.cordova.file;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FilterInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-
-public abstract class Filesystem {
-
- public String name;
-
- public interface ReadFileCallback {
- public void handleData(InputStream inputStream, String contentType) throws IOException;
- }
-
- public static JSONObject makeEntryForPath(String path, String fsName, Boolean isDir)
- throws JSONException {
- return makeEntryForPath(path, fsName, isDir, null);
- }
-
- public static JSONObject makeEntryForPath(String path, String fsName, Boolean isDir, String nativeURL)
- throws JSONException {
- JSONObject entry = new JSONObject();
-
- int end = path.endsWith("/") ? 1 : 0;
- String[] parts = path.substring(0,path.length()-end).split("/");
- String fileName = parts[parts.length-1];
- entry.put("isFile", !isDir);
- entry.put("isDirectory", isDir);
- entry.put("name", fileName);
- entry.put("fullPath", path);
- // The file system can't be specified, as it would lead to an infinite loop,
- // but the filesystem name can be.
- entry.put("filesystemName", fsName);
- // Backwards compatibility
- entry.put("filesystem", "temporary".equals(fsName) ? 0 : 1);
-
- if (nativeURL != null) {
- entry.put("nativeURL", nativeURL);
- }
- return entry;
-
- }
-
- public static JSONObject makeEntryForURL(LocalFilesystemURL inputURL, Boolean isDir) throws JSONException {
- return makeEntryForURL(inputURL, isDir, null);
- }
-
- public static JSONObject makeEntryForURL(LocalFilesystemURL inputURL, Boolean isDir, String nativeURL) throws JSONException {
- return makeEntryForPath(inputURL.fullPath, inputURL.filesystemName, isDir, nativeURL);
- }
-
- abstract JSONObject getEntryForLocalURL(LocalFilesystemURL inputURL) throws IOException;
-
- abstract JSONObject getFileForLocalURL(LocalFilesystemURL inputURL, String path,
- JSONObject options, boolean directory) throws FileExistsException, IOException, TypeMismatchException, EncodingException, JSONException;
-
- abstract boolean removeFileAtLocalURL(LocalFilesystemURL inputURL) throws InvalidModificationException, NoModificationAllowedException;
-
- abstract boolean recursiveRemoveFileAtLocalURL(LocalFilesystemURL inputURL) throws FileExistsException, NoModificationAllowedException;
-
- abstract JSONArray readEntriesAtLocalURL(LocalFilesystemURL inputURL) throws FileNotFoundException;
-
- abstract JSONObject getFileMetadataForLocalURL(LocalFilesystemURL inputURL) throws FileNotFoundException;
-
- public JSONObject getParentForLocalURL(LocalFilesystemURL inputURL) throws IOException {
- LocalFilesystemURL newURL = new LocalFilesystemURL(inputURL.URL);
-
- if (!("".equals(inputURL.fullPath) || "/".equals(inputURL.fullPath))) {
- int end = inputURL.fullPath.endsWith("/") ? 1 : 0;
- int lastPathStartsAt = inputURL.fullPath.lastIndexOf('/', inputURL.fullPath.length()-end)+1;
- newURL.fullPath = newURL.fullPath.substring(0,lastPathStartsAt);
- }
- return getEntryForLocalURL(newURL);
- }
-
- protected LocalFilesystemURL makeDestinationURL(String newName, LocalFilesystemURL srcURL, LocalFilesystemURL destURL) {
- // I know this looks weird but it is to work around a JSON bug.
- if ("null".equals(newName) || "".equals(newName)) {
- newName = srcURL.URL.getLastPathSegment();;
- }
-
- String newDest = destURL.URL.toString();
- if (newDest.endsWith("/")) {
- newDest = newDest + newName;
- } else {
- newDest = newDest + "/" + newName;
- }
- return new LocalFilesystemURL(newDest);
- }
-
- /* Read a source URL (possibly from a different filesystem, srcFs,) and copy it to
- * the destination URL on this filesystem, optionally with a new filename.
- * If move is true, then this method should either perform an atomic move operation
- * or remove the source file when finished.
- */
- JSONObject copyFileToURL(LocalFilesystemURL destURL, String newName,
- Filesystem srcFs, LocalFilesystemURL srcURL, boolean move) throws IOException, InvalidModificationException, JSONException, NoModificationAllowedException, FileExistsException {
- // This is "the hard way" -- transfer data between arbitrary filesystem urls/
- // Gets an input stream from src, and writes its contents to an output stream
- // from dest.
-
- // First, check to see that we can do it
- if (!move || srcFs.canRemoveFileAtLocalURL(srcURL)) {
- final LocalFilesystemURL destination = makeDestinationURL(newName, srcURL, destURL);
- srcFs.readFileAtURL(srcURL, 0, -1, new ReadFileCallback() {
- public void handleData(InputStream inputStream, String contentType) throws IOException {
- if (inputStream != null) {
- //write data to file
- OutputStream os = getOutputStreamForURL(destination);
- final int BUFFER_SIZE = 8192;
- byte[] buffer = new byte[BUFFER_SIZE];
-
- for (;;) {
- int bytesRead = inputStream.read(buffer, 0, BUFFER_SIZE);
-
- if (bytesRead <= 0) {
- break;
- }
- os.write(buffer, 0, bytesRead);
- }
- os.close();
- } else {
- throw new IOException("Cannot read file at source URL");
- }
- }
- });
- if (move) {
- // Delete original
- srcFs.removeFileAtLocalURL(srcURL);
- }
- return makeEntryForURL(destination, false);
- } else {
- throw new NoModificationAllowedException("Cannot move file at source URL");
- }
- }
-
- abstract OutputStream getOutputStreamForURL(LocalFilesystemURL inputURL) throws IOException;
-
- abstract void readFileAtURL(LocalFilesystemURL inputURL, long start, long end,
- ReadFileCallback readFileCallback) throws IOException;
-
- abstract long writeToFileAtURL(LocalFilesystemURL inputURL, String data, int offset,
- boolean isBinary) throws NoModificationAllowedException, IOException;
-
- abstract long truncateFileAtURL(LocalFilesystemURL inputURL, long size)
- throws IOException, NoModificationAllowedException;
-
- // This method should return null if filesystem urls cannot be mapped to paths
- abstract String filesystemPathForURL(LocalFilesystemURL url);
-
- abstract LocalFilesystemURL URLforFilesystemPath(String path);
-
- abstract boolean canRemoveFileAtLocalURL(LocalFilesystemURL inputURL);
-
- protected class LimitedInputStream extends FilterInputStream {
- long numBytesToRead;
- public LimitedInputStream(InputStream in, long numBytesToRead) {
- super(in);
- this.numBytesToRead = numBytesToRead;
- }
- @Override
- public int read() throws IOException {
- if (numBytesToRead <= 0) {
- return -1;
- }
- numBytesToRead--;
- return in.read();
- }
- @Override
- public int read(byte[] buffer, int byteOffset, int byteCount) throws IOException {
- if (numBytesToRead <= 0) {
- return -1;
- }
- int bytesToRead = byteCount;
- if (byteCount > numBytesToRead) {
- bytesToRead = (int)numBytesToRead; // Cast okay; long is less than int here.
- }
- int numBytesRead = in.read(buffer, byteOffset, bytesToRead);
- numBytesToRead -= numBytesRead;
- return numBytesRead;
- }
- }
-
- /* Create a FileEntry or DirectoryEntry given an actual file on device.
- * Return null if the file does not exist within this filesystem.
- */
- public JSONObject makeEntryForFile(File file) throws JSONException {
- return null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/9976b306/src/android/InvalidModificationException.java
----------------------------------------------------------------------
diff --git a/src/android/InvalidModificationException.java b/src/android/InvalidModificationException.java
deleted file mode 100644
index 8f6bec5..0000000
--- a/src/android/InvalidModificationException.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
-*/
-
-
-package org.apache.cordova.file;
-
-@SuppressWarnings("serial")
-public class InvalidModificationException extends Exception {
-
- public InvalidModificationException(String message) {
- super(message);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/9976b306/src/android/LocalFilesystem.java
----------------------------------------------------------------------
diff --git a/src/android/LocalFilesystem.java b/src/android/LocalFilesystem.java
deleted file mode 100644
index c0e14e4..0000000
--- a/src/android/LocalFilesystem.java
+++ /dev/null
@@ -1,644 +0,0 @@
-/*
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
- */
-package org.apache.cordova.file;
-
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.RandomAccessFile;
-import java.nio.channels.FileChannel;
-import java.util.ArrayList;
-import java.util.Arrays;
-
-import org.apache.cordova.CordovaInterface;
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-
-import android.util.Base64;
-import android.net.Uri;
-
-public class LocalFilesystem extends Filesystem {
-
- private String fsRoot;
- private CordovaInterface cordova;
-
- public LocalFilesystem(String name, CordovaInterface cordova, String fsRoot) {
- this.name = name;
- this.fsRoot = fsRoot;
- this.cordova = cordova;
- }
-
- public String filesystemPathForFullPath(String fullPath) {
- String path = new File(this.fsRoot, fullPath).toString();
- int questionMark = path.indexOf("?");
- if (questionMark >= 0) {
- path = path.substring(0, questionMark);
- }
- if (path.length() > 1 && path.endsWith("/")) {
- path = path.substring(0, path.length()-1);
- }
- return path;
- }
-
- @Override
- public String filesystemPathForURL(LocalFilesystemURL url) {
- return filesystemPathForFullPath(url.fullPath);
- }
-
- private String fullPathForFilesystemPath(String absolutePath) {
- if (absolutePath != null && absolutePath.startsWith(this.fsRoot)) {
- return absolutePath.substring(this.fsRoot.length());
- }
- return null;
- }
-
- protected LocalFilesystemURL URLforFullPath(String fullPath) {
- if (fullPath != null) {
- if (fullPath.startsWith("/")) {
- return new LocalFilesystemURL(LocalFilesystemURL.FILESYSTEM_PROTOCOL + "://localhost/"+this.name+fullPath);
- }
- return new LocalFilesystemURL(LocalFilesystemURL.FILESYSTEM_PROTOCOL + "://localhost/"+this.name+"/"+fullPath);
- }
- return null;
-
- }
-
- @Override
- public LocalFilesystemURL URLforFilesystemPath(String path) {
- return this.URLforFullPath(this.fullPathForFilesystemPath(path));
- }
-
- protected String normalizePath(String rawPath) {
- // If this is an absolute path, trim the leading "/" and replace it later
- boolean isAbsolutePath = rawPath.startsWith("/");
- if (isAbsolutePath) {
- rawPath = rawPath.substring(1);
- }
- ArrayList<String> components = new ArrayList<String>(Arrays.asList(rawPath.split("/")));
- for (int index = 0; index < components.size(); ++index) {
- if (components.get(index).equals("..")) {
- components.remove(index);
- if (index > 0) {
- components.remove(index-1);
- --index;
- }
- }
- }
- StringBuilder normalizedPath = new StringBuilder();
- for(String component: components) {
- normalizedPath.append("/");
- normalizedPath.append(component);
- }
- if (isAbsolutePath) {
- return normalizedPath.toString();
- } else {
- return normalizedPath.toString().substring(1);
- }
-
-
- }
-
-
- @Override
- public JSONObject makeEntryForFile(File file) throws JSONException {
- String path = this.fullPathForFilesystemPath(file.getAbsolutePath());
- if (path != null) {
- return makeEntryForPath(path, this.name, file.isDirectory(), Uri.fromFile(file).toString());
- }
- return null;
- }
-
- @Override
- public JSONObject getEntryForLocalURL(LocalFilesystemURL inputURL) throws IOException {
- File fp = new File(filesystemPathForURL(inputURL));
-
- if (!fp.exists()) {
- throw new FileNotFoundException();
- }
- if (!fp.canRead()) {
- throw new IOException();
- }
- try {
- JSONObject entry = new JSONObject();
- entry.put("isFile", fp.isFile());
- entry.put("isDirectory", fp.isDirectory());
- entry.put("name", fp.getName());
- entry.put("fullPath", inputURL.fullPath);
- // The file system can't be specified, as it would lead to an infinite loop.
- // But we can specify the name of the FS, and the rest can be reconstructed
- // in JS.
- entry.put("filesystemName", inputURL.filesystemName);
- // Backwards compatibility
- entry.put("filesystem", "temporary".equals(name) ? 0 : 1);
- entry.put("nativeURL", Uri.fromFile(fp).toString());
- return entry;
- } catch (JSONException e) {
- throw new IOException();
- }
- }
-
- @Override
- public JSONObject getFileForLocalURL(LocalFilesystemURL inputURL,
- String path, JSONObject options, boolean directory) throws FileExistsException, IOException, TypeMismatchException, EncodingException, JSONException {
- boolean create = false;
- boolean exclusive = false;
-
- if (options != null) {
- create = options.optBoolean("create");
- if (create) {
- exclusive = options.optBoolean("exclusive");
- }
- }
-
- // Check for a ":" character in the file to line up with BB and iOS
- if (path.contains(":")) {
- throw new EncodingException("This path has an invalid \":\" in it.");
- }
-
- LocalFilesystemURL requestedURL;
-
- // Check whether the supplied path is absolute or relative
- if (path.startsWith("/")) {
- requestedURL = URLforFilesystemPath(path);
- } else {
- requestedURL = URLforFullPath(normalizePath(inputURL.fullPath + "/" + path));
- }
-
- File fp = new File(this.filesystemPathForURL(requestedURL));
-
- if (create) {
- if (exclusive && fp.exists()) {
- throw new FileExistsException("create/exclusive fails");
- }
- if (directory) {
- fp.mkdir();
- } else {
- fp.createNewFile();
- }
- if (!fp.exists()) {
- throw new FileExistsException("create fails");
- }
- }
- else {
- if (!fp.exists()) {
- throw new FileNotFoundException("path does not exist");
- }
- if (directory) {
- if (fp.isFile()) {
- throw new TypeMismatchException("path doesn't exist or is file");
- }
- } else {
- if (fp.isDirectory()) {
- throw new TypeMismatchException("path doesn't exist or is directory");
- }
- }
- }
-
- // Return the directory
- return makeEntryForPath(requestedURL.fullPath, requestedURL.filesystemName, directory, Uri.fromFile(fp).toString());
- }
-
- @Override
- public boolean removeFileAtLocalURL(LocalFilesystemURL inputURL) throws InvalidModificationException {
-
- File fp = new File(filesystemPathForURL(inputURL));
-
- // You can't delete a directory that is not empty
- if (fp.isDirectory() && fp.list().length > 0) {
- throw new InvalidModificationException("You can't delete a directory that is not empty.");
- }
-
- return fp.delete();
- }
-
- @Override
- public boolean recursiveRemoveFileAtLocalURL(LocalFilesystemURL inputURL) throws FileExistsException {
- File directory = new File(filesystemPathForURL(inputURL));
- return removeDirRecursively(directory);
- }
-
- protected boolean removeDirRecursively(File directory) throws FileExistsException {
- if (directory.isDirectory()) {
- for (File file : directory.listFiles()) {
- removeDirRecursively(file);
- }
- }
-
- if (!directory.delete()) {
- throw new FileExistsException("could not delete: " + directory.getName());
- } else {
- return true;
- }
- }
-
- @Override
- public JSONArray readEntriesAtLocalURL(LocalFilesystemURL inputURL) throws FileNotFoundException {
- File fp = new File(filesystemPathForURL(inputURL));
-
- if (!fp.exists()) {
- // The directory we are listing doesn't exist so we should fail.
- throw new FileNotFoundException();
- }
-
- JSONArray entries = new JSONArray();
-
- if (fp.isDirectory()) {
- File[] files = fp.listFiles();
- for (int i = 0; i < files.length; i++) {
- if (files[i].canRead()) {
- try {
- entries.put(makeEntryForPath(fullPathForFilesystemPath(files[i].getAbsolutePath()), inputURL.filesystemName, files[i].isDirectory(), Uri.fromFile(files[i]).toString()));
- } catch (JSONException e) {
- }
- }
- }
- }
-
- return entries;
- }
-
- @Override
- public JSONObject getFileMetadataForLocalURL(LocalFilesystemURL inputURL) throws FileNotFoundException {
- File file = new File(filesystemPathForURL(inputURL));
-
- if (!file.exists()) {
- throw new FileNotFoundException("File at " + inputURL.URL + " does not exist.");
- }
-
- JSONObject metadata = new JSONObject();
- try {
- // Ensure that directories report a size of 0
- metadata.put("size", file.isDirectory() ? 0 : file.length());
- metadata.put("type", FileHelper.getMimeType(file.getAbsolutePath(), cordova));
- metadata.put("name", file.getName());
- metadata.put("fullPath", inputURL.fullPath);
- metadata.put("lastModifiedDate", file.lastModified());
- } catch (JSONException e) {
- return null;
- }
- return metadata;
- }
-
- /**
- * Check to see if the user attempted to copy an entry into its parent without changing its name,
- * or attempted to copy a directory into a directory that it contains directly or indirectly.
- *
- * @param srcDir
- * @param destinationDir
- * @return
- */
- private boolean isCopyOnItself(String src, String dest) {
-
- // This weird test is to determine if we are copying or moving a directory into itself.
- // Copy /sdcard/myDir to /sdcard/myDir-backup is okay but
- // Copy /sdcard/myDir to /sdcard/myDir/backup should throw an INVALID_MODIFICATION_ERR
- if (dest.startsWith(src) && dest.indexOf(File.separator, src.length() - 1) != -1) {
- return true;
- }
-
- return false;
- }
-
- /**
- * Copy a file
- *
- * @param srcFile file to be copied
- * @param destFile destination to be copied to
- * @return a FileEntry object
- * @throws IOException
- * @throws InvalidModificationException
- * @throws JSONException
- */
- private JSONObject copyFile(File srcFile, File destFile) throws IOException, InvalidModificationException, JSONException {
- // Renaming a file to an existing directory should fail
- if (destFile.exists() && destFile.isDirectory()) {
- throw new InvalidModificationException("Can't rename a file to a directory");
- }
-
- copyAction(srcFile, destFile);
-
- return makeEntryForFile(destFile);
- }
-
- /**
- * Moved this code into it's own method so moveTo could use it when the move is across file systems
- */
- private void copyAction(File srcFile, File destFile)
- throws FileNotFoundException, IOException {
- FileInputStream istream = new FileInputStream(srcFile);
- FileOutputStream ostream = new FileOutputStream(destFile);
- FileChannel input = istream.getChannel();
- FileChannel output = ostream.getChannel();
-
- try {
- input.transferTo(0, input.size(), output);
- } finally {
- istream.close();
- ostream.close();
- input.close();
- output.close();
- }
- }
-
- /**
- * Copy a directory
- *
- * @param srcDir directory to be copied
- * @param destinationDir destination to be copied to
- * @return a DirectoryEntry object
- * @throws JSONException
- * @throws IOException
- * @throws NoModificationAllowedException
- * @throws InvalidModificationException
- */
- private JSONObject copyDirectory(File srcDir, File destinationDir) throws JSONException, IOException, NoModificationAllowedException, InvalidModificationException {
- // Renaming a file to an existing directory should fail
- if (destinationDir.exists() && destinationDir.isFile()) {
- throw new InvalidModificationException("Can't rename a file to a directory");
- }
-
- // Check to make sure we are not copying the directory into itself
- if (isCopyOnItself(srcDir.getAbsolutePath(), destinationDir.getAbsolutePath())) {
- throw new InvalidModificationException("Can't copy itself into itself");
- }
-
- // See if the destination directory exists. If not create it.
- if (!destinationDir.exists()) {
- if (!destinationDir.mkdir()) {
- // If we can't create the directory then fail
- throw new NoModificationAllowedException("Couldn't create the destination directory");
- }
- }
-
-
- for (File file : srcDir.listFiles()) {
- File destination = new File(destinationDir.getAbsoluteFile() + File.separator + file.getName());
- if (file.isDirectory()) {
- copyDirectory(file, destination);
- } else {
- copyFile(file, destination);
- }
- }
-
- return makeEntryForFile(destinationDir);
- }
-
- /**
- * Move a file
- *
- * @param srcFile file to be copied
- * @param destFile destination to be copied to
- * @return a FileEntry object
- * @throws IOException
- * @throws InvalidModificationException
- * @throws JSONException
- */
- private JSONObject moveFile(File srcFile, File destFile) throws IOException, JSONException, InvalidModificationException {
- // Renaming a file to an existing directory should fail
- if (destFile.exists() && destFile.isDirectory()) {
- throw new InvalidModificationException("Can't rename a file to a directory");
- }
-
- // Try to rename the file
- if (!srcFile.renameTo(destFile)) {
- // Trying to rename the file failed. Possibly because we moved across file system on the device.
- // Now we have to do things the hard way
- // 1) Copy all the old file
- // 2) delete the src file
- copyAction(srcFile, destFile);
- if (destFile.exists()) {
- srcFile.delete();
- } else {
- throw new IOException("moved failed");
- }
- }
-
- return makeEntryForFile(destFile);
- }
-
- /**
- * Move a directory
- *
- * @param srcDir directory to be copied
- * @param destinationDir destination to be copied to
- * @return a DirectoryEntry object
- * @throws JSONException
- * @throws IOException
- * @throws InvalidModificationException
- * @throws NoModificationAllowedException
- * @throws FileExistsException
- */
- private JSONObject moveDirectory(File srcDir, File destinationDir) throws IOException, JSONException, InvalidModificationException, NoModificationAllowedException, FileExistsException {
- // Renaming a file to an existing directory should fail
- if (destinationDir.exists() && destinationDir.isFile()) {
- throw new InvalidModificationException("Can't rename a file to a directory");
- }
-
- // Check to make sure we are not copying the directory into itself
- if (isCopyOnItself(srcDir.getAbsolutePath(), destinationDir.getAbsolutePath())) {
- throw new InvalidModificationException("Can't move itself into itself");
- }
-
- // If the destination directory already exists and is empty then delete it. This is according to spec.
- if (destinationDir.exists()) {
- if (destinationDir.list().length > 0) {
- throw new InvalidModificationException("directory is not empty");
- }
- }
-
- // Try to rename the directory
- if (!srcDir.renameTo(destinationDir)) {
- // Trying to rename the directory failed. Possibly because we moved across file system on the device.
- // Now we have to do things the hard way
- // 1) Copy all the old files
- // 2) delete the src directory
- copyDirectory(srcDir, destinationDir);
- if (destinationDir.exists()) {
- removeDirRecursively(srcDir);
- } else {
- throw new IOException("moved failed");
- }
- }
-
- return makeEntryForFile(destinationDir);
- }
-
- @Override
- public JSONObject copyFileToURL(LocalFilesystemURL destURL, String newName,
- Filesystem srcFs, LocalFilesystemURL srcURL, boolean move) throws IOException, InvalidModificationException, JSONException, NoModificationAllowedException, FileExistsException {
-
- // Check to see if the destination directory exists
- String newParent = this.filesystemPathForURL(destURL);
- File destinationDir = new File(newParent);
- if (!destinationDir.exists()) {
- // The destination does not exist so we should fail.
- throw new FileNotFoundException("The source does not exist");
- }
-
- if (LocalFilesystem.class.isInstance(srcFs)) {
- /* Same FS, we can shortcut with NSFileManager operations */
-
- // Figure out where we should be copying to
- final LocalFilesystemURL destinationURL = makeDestinationURL(newName, srcURL, destURL);
-
- String srcFilesystemPath = srcFs.filesystemPathForURL(srcURL);
- File sourceFile = new File(srcFilesystemPath);
- String destFilesystemPath = this.filesystemPathForURL(destinationURL);
- File destinationFile = new File(destFilesystemPath);
-
- if (!sourceFile.exists()) {
- // The file/directory we are copying doesn't exist so we should fail.
- throw new FileNotFoundException("The source does not exist");
- }
-
- // Check to see if source and destination are the same file
- if (sourceFile.getAbsolutePath().equals(destinationFile.getAbsolutePath())) {
- throw new InvalidModificationException("Can't copy a file onto itself");
- }
-
- if (sourceFile.isDirectory()) {
- if (move) {
- return moveDirectory(sourceFile, destinationFile);
- } else {
- return copyDirectory(sourceFile, destinationFile);
- }
- } else {
- if (move) {
- return moveFile(sourceFile, destinationFile);
- } else {
- return copyFile(sourceFile, destinationFile);
- }
- }
-
- } else {
- // Need to copy the hard way
- return super.copyFileToURL(destURL, newName, srcFs, srcURL, move);
- }
- }
-
- @Override
- public void readFileAtURL(LocalFilesystemURL inputURL, long start, long end,
- ReadFileCallback readFileCallback) throws IOException {
-
- File file = new File(this.filesystemPathForURL(inputURL));
- String contentType = FileHelper.getMimeTypeForExtension(file.getAbsolutePath());
-
- if (end < 0) {
- end = file.length();
- }
- long numBytesToRead = end - start;
-
- InputStream rawInputStream = new FileInputStream(file);
- try {
- if (start > 0) {
- rawInputStream.skip(start);
- }
- LimitedInputStream inputStream = new LimitedInputStream(rawInputStream, numBytesToRead);
- readFileCallback.handleData(inputStream, contentType);
- } finally {
- rawInputStream.close();
- }
- }
-
- @Override
- public long writeToFileAtURL(LocalFilesystemURL inputURL, String data,
- int offset, boolean isBinary) throws IOException, NoModificationAllowedException {
-
- boolean append = false;
- if (offset > 0) {
- this.truncateFileAtURL(inputURL, offset);
- append = true;
- }
-
- byte[] rawData;
- if (isBinary) {
- rawData = Base64.decode(data, Base64.DEFAULT);
- } else {
- rawData = data.getBytes();
- }
- ByteArrayInputStream in = new ByteArrayInputStream(rawData);
- try
- {
- byte buff[] = new byte[rawData.length];
- FileOutputStream out = new FileOutputStream(this.filesystemPathForURL(inputURL), append);
- try {
- in.read(buff, 0, buff.length);
- out.write(buff, 0, rawData.length);
- out.flush();
- } finally {
- // Always close the output
- out.close();
- }
- }
- catch (NullPointerException e)
- {
- // This is a bug in the Android implementation of the Java Stack
- NoModificationAllowedException realException = new NoModificationAllowedException(inputURL.toString());
- throw realException;
- }
-
- return rawData.length;
- }
-
- @Override
- public long truncateFileAtURL(LocalFilesystemURL inputURL, long size) throws IOException {
- File file = new File(filesystemPathForURL(inputURL));
-
- if (!file.exists()) {
- throw new FileNotFoundException("File at " + inputURL.URL + " does not exist.");
- }
-
- RandomAccessFile raf = new RandomAccessFile(filesystemPathForURL(inputURL), "rw");
- try {
- if (raf.length() >= size) {
- FileChannel channel = raf.getChannel();
- channel.truncate(size);
- return size;
- }
-
- return raf.length();
- } finally {
- raf.close();
- }
-
-
- }
-
- @Override
- public boolean canRemoveFileAtLocalURL(LocalFilesystemURL inputURL) {
- String path = filesystemPathForURL(inputURL);
- File file = new File(path);
- return file.exists();
- }
-
- @Override
- OutputStream getOutputStreamForURL(LocalFilesystemURL inputURL) throws FileNotFoundException {
- String path = filesystemPathForURL(inputURL);
- File file = new File(path);
- FileOutputStream os = new FileOutputStream(file);
- return os;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/9976b306/src/android/LocalFilesystemURL.java
----------------------------------------------------------------------
diff --git a/src/android/LocalFilesystemURL.java b/src/android/LocalFilesystemURL.java
deleted file mode 100644
index 2bf40c3..0000000
--- a/src/android/LocalFilesystemURL.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
- */
-package org.apache.cordova.file;
-
-import java.util.List;
-
-import android.net.Uri;
-
-public class LocalFilesystemURL {
-
- public static final String FILESYSTEM_PROTOCOL = "cdvfile";
-
- Uri URL;
- String filesystemName;
- String fullPath;
-
- public LocalFilesystemURL(Uri URL) {
- this.URL = URL;
- this.filesystemName = this.filesystemNameForLocalURL(URL);
- this.fullPath = this.fullPathForLocalURL(URL);
- }
-
- private String fullPathForLocalURL(Uri URL) {
- if (FILESYSTEM_PROTOCOL.equals(URL.getScheme()) && "localhost".equals(URL.getHost())) {
- String path = URL.getPath();
- if (URL.getQuery() != null) {
- path = path + "?" + URL.getQuery();
- }
- return path.substring(path.indexOf('/', 1));
- } else if ("content".equals(URL.getScheme())) {
- String path = '/' + URL.getHost() + URL.getPath();
- // Re-encode path component to handle Android 4.4+ Content URLs
- return Uri.encode(path,"/");
- }
- return null;
- }
-
- private String filesystemNameForLocalURL(Uri URL) {
- if (FILESYSTEM_PROTOCOL.equals(URL.getScheme()) && "localhost".equals(URL.getHost())) {
- List<String> pathComponents = URL.getPathSegments();
- if (pathComponents != null && pathComponents.size() > 0) {
- return pathComponents.get(0);
- }
- return null;
- } else if ("content".equals(URL.getScheme())) {
- return "content";
- }
- return null;
- }
-
- public LocalFilesystemURL(String strURL) {
- this(Uri.parse(strURL));
- }
-
- public String toString() {
- return "cdvfile://localhost/" + this.filesystemName + this.fullPath;
- }
-}
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/9976b306/src/android/NoModificationAllowedException.java
----------------------------------------------------------------------
diff --git a/src/android/NoModificationAllowedException.java b/src/android/NoModificationAllowedException.java
deleted file mode 100644
index 627eafb..0000000
--- a/src/android/NoModificationAllowedException.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
-*/
-
-package org.apache.cordova.file;
-
-@SuppressWarnings("serial")
-public class NoModificationAllowedException extends Exception {
-
- public NoModificationAllowedException(String message) {
- super(message);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/9976b306/src/android/TypeMismatchException.java
----------------------------------------------------------------------
diff --git a/src/android/TypeMismatchException.java b/src/android/TypeMismatchException.java
deleted file mode 100644
index 1315f9a..0000000
--- a/src/android/TypeMismatchException.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
-*/
-
-
-package org.apache.cordova.file;
-
-@SuppressWarnings("serial")
-public class TypeMismatchException extends Exception {
-
- public TypeMismatchException(String message) {
- super(message);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/9976b306/src/blackberry10/index.js
----------------------------------------------------------------------
diff --git a/src/blackberry10/index.js b/src/blackberry10/index.js
deleted file mode 100644
index 1e480b5..0000000
--- a/src/blackberry10/index.js
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-module.exports = {
- setSandbox : function (success, fail, args, env) {
- require("lib/webview").setSandbox(JSON.parse(decodeURIComponent(args[0])));
- new PluginResult(args, env).ok();
- },
-
- isSandboxed : function (success, fail, args, env) {
- new PluginResult(args, env).ok(require("lib/webview").getSandbox() === "1");
- },
-
- resolveLocalPath : function (success, fail, args, env) {
- var homeDir = window.qnx.webplatform.getApplication().getEnv("HOME").replace("/data", "/app/native/"),
- path = homeDir + JSON.parse(decodeURIComponent(args[0])).substring(9);
- require("lib/webview").setSandbox(false);
- new PluginResult(args, env).ok(path);
- }
-};
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/9976b306/src/ios/CDVAssetLibraryFilesystem.h
----------------------------------------------------------------------
diff --git a/src/ios/CDVAssetLibraryFilesystem.h b/src/ios/CDVAssetLibraryFilesystem.h
deleted file mode 100644
index e09e225..0000000
--- a/src/ios/CDVAssetLibraryFilesystem.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
- */
-
-#import "CDVFile.h"
-
-extern NSString* const kCDVAssetsLibraryPrefix;
-extern NSString* const kCDVAssetsLibraryScheme;
-
-@interface CDVAssetLibraryFilesystem : NSObject<CDVFileSystem> {
-}
-
-- (id) initWithName:(NSString *)name;
-
-@end