mirror of
https://github.com/apache/cordova-android.git
synced 2025-01-19 15:12:51 +08:00
Use strings not objects
This commit is contained in:
parent
49d8d22d7f
commit
9fe1f21c9f
@ -185,11 +185,11 @@ public class FileUtils extends Plugin {
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
else if (action.equals("readEntries")) {
|
||||
@ -281,6 +281,10 @@ public class FileUtils extends Plugin {
|
||||
* @throws JSONException
|
||||
*/
|
||||
private JSONArray readEntries(String fileName) throws FileNotFoundException, JSONException {
|
||||
if (fileName.startsWith("file://")) {
|
||||
fileName = fileName.substring(7);
|
||||
}
|
||||
|
||||
File fp = new File(fileName);
|
||||
|
||||
if (!fp.exists()) {
|
||||
@ -314,7 +318,15 @@ public class FileUtils extends Plugin {
|
||||
* @throws EncodingException
|
||||
* @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
|
||||
if (newName != null && newName.contains(":")) {
|
||||
throw new EncodingException("Bad file name");
|
||||
@ -327,7 +339,7 @@ public class FileUtils extends Plugin {
|
||||
throw new FileNotFoundException("The source does not exist");
|
||||
}
|
||||
|
||||
File destinationDir = new File(newParent.getString("fullPath"));
|
||||
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");
|
||||
|
Loading…
Reference in New Issue
Block a user