OSDN Git Service

Fix slash in paths for ListCommand
authorjruesga <jorge@ruesga.com>
Sat, 6 Oct 2012 23:34:18 +0000 (01:34 +0200)
committerjruesga <jorge@ruesga.com>
Sat, 6 Oct 2012 23:34:18 +0000 (01:34 +0200)
src/com/cyanogenmod/explorer/commands/shell/ListCommand.java

index 0a058e2..d2f1b4f 100644 (file)
@@ -84,11 +84,11 @@ public class ListCommand extends SyncResultProgram implements ListExecutable {
         //If the mode is listing directory, for avoid problems with symlink,
         //always append a / to the end of the path (if not exists)
         super(mode.compareTo(LIST_MODE.DIRECTORY) == 0 ? ID_LS_DIRECTORY : ID_LS_INFO,
-                new String[]{ mode.compareTo(LIST_MODE.DIRECTORY) == 0
-                ? (src.endsWith(File.separator)
-                        ? src
-                        : src + File.separator)
-                : src});
+                new String[]{
+                        mode.compareTo(LIST_MODE.DIRECTORY) == 0
+                            ? FileHelper.addTrailingSlash(src)
+                            : FileHelper.removeTrailingSlash(src)
+                    });
 
         //Initialize files to something distinct of null
         this.mFiles = new ArrayList<FileSystemObject>();
@@ -108,7 +108,9 @@ public class ListCommand extends SyncResultProgram implements ListExecutable {
         } else {
             //Get the absolute path
             try {
-                this.mParentDir = new File(src).getCanonicalFile().getParent();
+                this.mParentDir =
+                        FileHelper.removeTrailingSlash(
+                                new File(src).getCanonicalFile().getParent());
 
             } catch (Exception e) {
                 // Try to resolve from a console