forked from github/cordova-android
Use strings not objects
This commit is contained in:
parent
a52ba37cf7
commit
d87ee719a3
@ -185,11 +185,11 @@ public class FileUtils extends Plugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (action.equals("moveTo")) {
|
else if (action.equals("moveTo")) {
|
||||||
JSONObject entry = transferTo(args.getString(0), args.getJSONObject(1), args.optString(2), true);
|
JSONObject entry = transferTo(args.getString(0), args.getString(1), args.getString(2), true);
|
||||||
return new PluginResult(status, entry);
|
return new PluginResult(status, entry);
|
||||||
}
|
}
|
||||||
else if (action.equals("copyTo")) {
|
else if (action.equals("copyTo")) {
|
||||||
JSONObject entry = transferTo(args.getString(0), args.getJSONObject(1), args.optString(2), false);
|
JSONObject entry = transferTo(args.getString(0), args.getString(1), args.getString(2), false);
|
||||||
return new PluginResult(status, entry);
|
return new PluginResult(status, entry);
|
||||||
}
|
}
|
||||||
else if (action.equals("readEntries")) {
|
else if (action.equals("readEntries")) {
|
||||||
@ -281,6 +281,10 @@ public class FileUtils extends Plugin {
|
|||||||
* @throws JSONException
|
* @throws JSONException
|
||||||
*/
|
*/
|
||||||
private JSONArray readEntries(String fileName) throws FileNotFoundException, JSONException {
|
private JSONArray readEntries(String fileName) throws FileNotFoundException, JSONException {
|
||||||
|
if (fileName.startsWith("file://")) {
|
||||||
|
fileName = fileName.substring(7);
|
||||||
|
}
|
||||||
|
|
||||||
File fp = new File(fileName);
|
File fp = new File(fileName);
|
||||||
|
|
||||||
if (!fp.exists()) {
|
if (!fp.exists()) {
|
||||||
@ -314,7 +318,15 @@ public class FileUtils extends Plugin {
|
|||||||
* @throws EncodingException
|
* @throws EncodingException
|
||||||
* @throws JSONException
|
* @throws JSONException
|
||||||
*/
|
*/
|
||||||
private JSONObject transferTo(String fileName, JSONObject newParent, String newName, boolean move) throws JSONException, NoModificationAllowedException, IOException, InvalidModificationException, EncodingException {
|
private JSONObject transferTo(String fileName, String newParent, String newName, boolean move) throws JSONException, NoModificationAllowedException, IOException, InvalidModificationException, EncodingException {
|
||||||
|
if (fileName.startsWith("file://")) {
|
||||||
|
fileName = fileName.substring(7);
|
||||||
|
}
|
||||||
|
if (newParent.startsWith("file://")) {
|
||||||
|
newParent = newParent.substring(7);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Check for invalid file name
|
// Check for invalid file name
|
||||||
if (newName != null && newName.contains(":")) {
|
if (newName != null && newName.contains(":")) {
|
||||||
throw new EncodingException("Bad file name");
|
throw new EncodingException("Bad file name");
|
||||||
@ -327,7 +339,7 @@ public class FileUtils extends Plugin {
|
|||||||
throw new FileNotFoundException("The source does not exist");
|
throw new FileNotFoundException("The source does not exist");
|
||||||
}
|
}
|
||||||
|
|
||||||
File destinationDir = new File(newParent.getString("fullPath"));
|
File destinationDir = new File(newParent);
|
||||||
if (!destinationDir.exists()) {
|
if (!destinationDir.exists()) {
|
||||||
// The destination does not exist so we should fail.
|
// The destination does not exist so we should fail.
|
||||||
throw new FileNotFoundException("The source does not exist");
|
throw new FileNotFoundException("The source does not exist");
|
||||||
|
Loading…
Reference in New Issue
Block a user