You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by bo...@apache.org on 2013/03/07 22:06:30 UTC
[2/4] android commit: moveFile handles absolute paths by not
pre-pending anything to them
moveFile handles absolute paths by not pre-pending anything to them
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/0ae49ed0
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/0ae49ed0
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/0ae49ed0
Branch: refs/heads/master
Commit: 0ae49ed098f9202fc3ccf66cfad7fcc0daeb2266
Parents: b8e5aaf
Author: lenny <gi...@sweetleon.com>
Authored: Fri Mar 1 22:11:29 2013 -0800
Committer: lenny <gi...@sweetleon.com>
Committed: Fri Mar 1 22:11:29 2013 -0800
----------------------------------------------------------------------
framework/src/org/apache/cordova/AudioPlayer.java | 15 ++++++++++-----
1 files changed, 10 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/0ae49ed0/framework/src/org/apache/cordova/AudioPlayer.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/AudioPlayer.java b/framework/src/org/apache/cordova/AudioPlayer.java
index 99dbb3d..0170728 100644
--- a/framework/src/org/apache/cordova/AudioPlayer.java
+++ b/framework/src/org/apache/cordova/AudioPlayer.java
@@ -167,13 +167,18 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
public void moveFile(String file) {
/* this is a hack to save the file as the specified name */
File f = new File(this.tempFile);
- if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
- f.renameTo(new File(Environment.getExternalStorageDirectory().getAbsolutePath()
- + File.separator + file));
- } else {
- f.renameTo(new File("/data/data/" + handler.cordova.getActivity().getPackageName() + "/cache/" + file));
+
+ if (!file.startsWith("/")) {
+ if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
+ file = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + file;
+ } else {
+ file = "/data/data/" + handler.cordova.getActivity().getPackageName() + "/cache/" + file;
+ }
}
+ String logMsg = "renaming " + this.tempFile + " to " + file;
+ Log.d(LOG_TAG, logMsg);
+ if (!f.renameTo(new File(file))) Log.e(LOG_TAG, "FAILED " + logMsg);
}
/**