diff options
| author | Jorge Ruesga <jorge@ruesga.com> | 2012-11-13 01:57:16 +0100 |
|---|---|---|
| committer | Jorge Ruesga <jorge@ruesga.com> | 2012-11-13 01:57:16 +0100 |
| commit | 32331d73021a9b4a96c973e7f054666da31d653d (patch) | |
| tree | 884987dcbaf437e54e161206ebfbc1a142dfc857 /src/com/cyanogenmod/filemanager/commands/java/MoveCommand.java | |
| parent | 79d1b6ebba9af3cc83c627f5aeab6ddb9bd75fe0 (diff) | |
CMFileManager: Fixes for non-rooted devices
Various fixes for non-rooted devices running under java console:
* Improve navigation (caching unsused data on chrooted mode: aids, mountpoints, ...)
* Editor: Don't ask user to gain privileges (non rooted devices never can gain privileged access)
* Move common file operations to FileHelper
* MoveCommand: As shell console, java console doesn't allow to move between filesystems. Use
a copy-delete operation when renameTo is not allowed.
* On non-rooted devices, not allow to change to other access mode.
Change-Id: I7ae8b4f4203fc8a20f498e43f45c0a956731b02e
Diffstat (limited to 'src/com/cyanogenmod/filemanager/commands/java/MoveCommand.java')
| -rw-r--r-- | src/com/cyanogenmod/filemanager/commands/java/MoveCommand.java | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/src/com/cyanogenmod/filemanager/commands/java/MoveCommand.java b/src/com/cyanogenmod/filemanager/commands/java/MoveCommand.java index f94e7f1..b0c85fb 100644 --- a/src/com/cyanogenmod/filemanager/commands/java/MoveCommand.java +++ b/src/com/cyanogenmod/filemanager/commands/java/MoveCommand.java @@ -23,6 +23,7 @@ import com.cyanogenmod.filemanager.console.ExecutionException; import com.cyanogenmod.filemanager.console.InsufficientPermissionsException; import com.cyanogenmod.filemanager.console.NoSuchFileOrDirectory; import com.cyanogenmod.filemanager.model.MountPoint; +import com.cyanogenmod.filemanager.util.FileHelper; import com.cyanogenmod.filemanager.util.MountPointHelper; import java.io.File; @@ -78,12 +79,34 @@ public class MoveCommand extends Program implements MoveExecutable { throw new NoSuchFileOrDirectory(this.mSrc); } - //Copy recursively - if (!s.renameTo(d)) { - if (isTrace()) { - Log.v(TAG, "Result: FAIL. InsufficientPermissionsException"); //$NON-NLS-1$ + //Move or copy recursively + if (d.exists()) { + if (!FileHelper.copyRecursive(s, d, getBufferSize())) { + if (isTrace()) { + Log.v(TAG, "Result: FAIL. InsufficientPermissionsException"); //$NON-NLS-1$ + } + throw new InsufficientPermissionsException(); + } + if (!FileHelper.deleteFolder(s)) { + if (isTrace()) { + Log.v(TAG, "Result: OK. WARNING. Source not deleted."); //$NON-NLS-1$ + } + } + } else { + // Move between filesystem is not allow. If rename fails then use copy operation + if (!s.renameTo(d)) { + if (!FileHelper.copyRecursive(s, d, getBufferSize())) { + if (isTrace()) { + Log.v(TAG, "Result: FAIL. InsufficientPermissionsException"); //$NON-NLS-1$ + } + throw new InsufficientPermissionsException(); + } + if (!FileHelper.deleteFolder(s)) { + if (isTrace()) { + Log.v(TAG, "Result: OK. WARNING. Source not deleted."); //$NON-NLS-1$ + } + } } - throw new InsufficientPermissionsException(); } if (isTrace()) { |
