From 0f5ff43701cddfd37f436a4db903e894e0de95b7 Mon Sep 17 00:00:00 2001 From: YoonKi Park Date: Wed, 21 Sep 2011 13:46:55 +0900 Subject: [PATCH] [Title] support linked file listing --- .../slp/common/connection/ConnectionActivator.java | 2 +- .../connection/ddmlib/FileListingService.java | 87 ++++++++++++++-------- .../ui/ConnectionExplorerContentProvider.java | 2 + 3 files changed, 57 insertions(+), 34 deletions(-) diff --git a/com.samsung.slp.common.connection/src/com/samsung/slp/common/connection/ConnectionActivator.java b/com.samsung.slp.common.connection/src/com/samsung/slp/common/connection/ConnectionActivator.java index baa8bac..2142ea1 100644 --- a/com.samsung.slp.common.connection/src/com/samsung/slp/common/connection/ConnectionActivator.java +++ b/com.samsung.slp.common.connection/src/com/samsung/slp/common/connection/ConnectionActivator.java @@ -70,7 +70,7 @@ public class ConnectionActivator extends AbstractUIPlugin { this.OS = this.LINUX; AndroidDebugBridge.init(false); - AndroidDebugBridge.createBridge("/home/kenoz/sdb/adb",true); + AndroidDebugBridge.createBridge("/home/mustafa/mywork/source/sdb/bin/adb",true); // get the eclipse store final IPreferenceStore eclipseStore = getPreferenceStore(); diff --git a/com.samsung.slp.common.connection/src/com/samsung/slp/common/connection/ddmlib/FileListingService.java b/com.samsung.slp.common.connection/src/com/samsung/slp/common/connection/ddmlib/FileListingService.java index 9005ccc..03fbbc4 100644 --- a/com.samsung.slp.common.connection/src/com/samsung/slp/common/connection/ddmlib/FileListingService.java +++ b/com.samsung.slp.common.connection/src/com/samsung/slp/common/connection/ddmlib/FileListingService.java @@ -16,7 +16,6 @@ package com.samsung.slp.common.connection.ddmlib; -import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; @@ -108,14 +107,14 @@ public final class FileListingService { private static String patternDate = "([a-zA-Z]{3}\\s+\\d{1,2})"; private static String patternTime = "(\\d{1,2}:\\d{1,2})"; private static String patternName = "(.*)"; - private static String patternLsEmulator = "^" + patternPermisions + "\\s+" + private static String patternLs = "^" + patternPermisions + "\\s+" + patternFilecount + "\\s+" + patternOwner + "\\s+" + patternGroup + "\\s+" + patternSize + "\\s+" + patternDate + "\\s+" + patternTime + "\\s+" + patternName + "$"; // private static Pattern sLsPattern = Pattern.compile( // "^([bcdlsp-][-r][-w][-xsS][-r][-w][-xsS][-r][-w][-xstST])\\s+(\\S+)\\s+(\\S+)\\s+([\\d\\s,]*)\\s+(\\d{4}-\\d\\d-\\d\\d)\\s+(\\d\\d:\\d\\d)\\s+(.*)$"); //$NON-NLS-1$ - private static Pattern sLsPattern = Pattern.compile(patternLsEmulator); + private static Pattern sLsPattern = Pattern.compile(patternLs); private Device mDevice; private FileEntry mRoot; @@ -152,7 +151,7 @@ public final class FileListingService { String time; String owner; String group; - String linkTo; + String linkPath; FileListingService fileListingService; int type; boolean isAppPackage; @@ -242,8 +241,8 @@ public final class FileListingService { public String getInfo() { return info; } - public String getLinkTo() { - return linkTo; + public String getLinkFullPath() { + return linkPath; } /** * Return the full path of the entry. @@ -473,25 +472,6 @@ public final class FileListingService { // get the name String name = m.group(8); - - // if the parent is root, we only accept selected - // items - // if (mParentEntry.isRoot()) { - // boolean found = false; - // for (String approved : sRootLevelApprovedItems) { - // if (approved.equals(name)) { - // found = true; - // break; - // } - // } - // - // // if it's not in the approved list we skip this - // entry. - // if (found == false) { - // continue; - // } - // } - // get the rest of the groups String permissions = m.group(1); String owner = m.group(3); @@ -520,8 +500,26 @@ public final class FileListingService { // add an arrow in front to specify // it's a link. info = "-> " + info; //$NON-NLS-1$; - } + // now get the path to the link + String[] pathSegments = info.split(FILE_SEPARATOR); + + if (pathSegments.length >= 1) { + // FIXME : not fully impl + String command = "ls -al "; + if (linkTo.charAt(0) != '/') + command = command + "/"; + command = command + linkTo; + try { + LsLinkReceiver receiver = new LsLinkReceiver(); + mDevice.executeShellCommand(command,receiver); + if (receiver.isDirectoryLink == true) + objectType = TYPE_DIRECTORY_LINK; + } catch (Exception e) { + // adb failed somehow, we do nothing. + } + } } + } // get the entry, either from an existing one, or a // new one FileEntry entry = getExistingEntry(name); @@ -536,15 +534,38 @@ public final class FileListingService { entry.time = time; entry.owner = owner; entry.group = group; - if (objectType == TYPE_LINK) { + if (objectType == TYPE_LINK || objectType == TYPE_DIRECTORY_LINK) { entry.info = info; - entry.linkTo = linkTo; + entry.linkPath = linkTo; } mEntryList.add(entry); } } - + final class LsLinkReceiver extends MultiLineReceiver { + boolean isDirectoryLink = false; + @Override + public void processNewLines(String[] lines) { + for (String line : lines) { + if (line.length() > 0) { + Matcher m = sLsPattern.matcher(line); + if (m.matches()) { + int objectType = getFileType(m.group(1).charAt(0)); + String name = m.group(8); + if (".".equals(name) && objectType == TYPE_DIRECTORY) { + isDirectoryLink = true; + break; + } + } + } + } + + } + + public boolean isCancelled() { + return false; + } + } /** * Queries for an already existing Entry per name * @@ -805,11 +826,11 @@ public final class FileListingService { try { // create the command String command = null; - if (entry.getType() == FileListingService.TYPE_LINK) { - if (entry.getLinkTo().charAt(0) == '/') - command = "ls -l " + entry.getLinkTo(); //$NON-NLS-1$ + if (entry.getType() == FileListingService.TYPE_LINK || entry.getType() == FileListingService.TYPE_DIRECTORY_LINK) { + if (entry.getLinkFullPath().charAt(0) == '/') + command = "ls -l " + entry.getLinkFullPath(); //$NON-NLS-1$ else - command = "ls -l /" + entry.getLinkTo(); //$NON-NLS-1$ + command = "ls -l /" + entry.getLinkFullPath(); //$NON-NLS-1$ }else { command = "ls -l " + entry.getFullPath(); //$NON-NLS-1$ } diff --git a/com.samsung.slp.common.connection/src/com/samsung/slp/common/connection/ui/ConnectionExplorerContentProvider.java b/com.samsung.slp.common.connection/src/com/samsung/slp/common/connection/ui/ConnectionExplorerContentProvider.java index de09b19..5404de7 100644 --- a/com.samsung.slp.common.connection/src/com/samsung/slp/common/connection/ui/ConnectionExplorerContentProvider.java +++ b/com.samsung.slp.common.connection/src/com/samsung/slp/common/connection/ui/ConnectionExplorerContentProvider.java @@ -133,6 +133,8 @@ public class ConnectionExplorerContentProvider implements ITreeContentProvider FileEntry entry = (FileEntry) arg0; if (entry.getType() == FileListingService.TYPE_DIRECTORY_LINK) return true; + else if (entry.getType() == FileListingService.TYPE_LINK) + return true; else if (entry.getType() == FileListingService.TYPE_DIRECTORY) return true; else if (entry.getType() == FileListingService.TYPE_ROOT_EMULATOR) -- 2.7.4