FUNCTION: bug fix of source link on platform project 73/29173/1
authorwoojin <woojin2.jung@samsung.com>
Wed, 22 Oct 2014 00:51:53 +0000 (09:51 +0900)
committerwoojin <woojin2.jung@samsung.com>
Wed, 22 Oct 2014 00:51:53 +0000 (09:51 +0900)
bug fix - enable source link on platform project
findFileRecursive function now finds directory too

Change-Id: I73072f28eb013d43a93650f10440131ec6862e34
Signed-off-by: woojin <woojin2.jung@samsung.com>
org.tizen.dynamicanalyzer.common/src/org/tizen/dynamicanalyzer/util/FileUtil.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/project/AppInfo.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/platform/BinarySettingManager.java

index 5d8fd04..d9099d0 100644 (file)
@@ -186,18 +186,24 @@ public class FileUtil {
        }
 
        private static void findFileRecursive(File rootPath, String regex, boolean recursive,
-                       List<String> result) throws FileNotFoundException, IOException {
+                       boolean isFile, List<String> result) throws FileNotFoundException, IOException {
                File[] filesAndDirs = rootPath.listFiles();
                if (null == filesAndDirs) { // if rootPath is not a directory
                        return;
                }
 
                for (File file : filesAndDirs) {
-                       if (file.isFile() && file.getName().matches(regex)) {
-                               result.add(file.getCanonicalPath()); // add to result if it's
-                                                                                                               // file
-                       } else if (recursive) {
-                               findFileRecursive(file, regex, recursive, result); // recursive
+                       if (file.isFile()) { // file
+                               if (isFile && file.getName().matches(regex)) {
+                                       result.add(file.getCanonicalPath()); // add to result if it's file
+                               }
+                       } else { // directory
+                               if (!isFile && file.getName().matches(regex)) {
+                                       result.add(file.getCanonicalPath());
+                               }
+                               if (recursive) {
+                                       findFileRecursive(file, regex, recursive, isFile, result); // recursive
+                               }
                        }
                }
        }
@@ -212,14 +218,14 @@ public class FileUtil {
         *            glob pattern of file name
         * @return canonical file path list
         */
-       public static List<String> findFilesInDir(String dirPath, String fileToken) {
+       public static List<String> findFilesInDir(String dirPath, String fileToken, boolean isFile) {
                List<String> resultFiles = new ArrayList<String>();
 
                String regex = convertGlobToRegex(fileToken);
                File startingDir = new File(dirPath);
                if (startingDir.exists()) {
                        try {
-                               findFileRecursive(startingDir, regex, true, resultFiles);
+                               findFileRecursive(startingDir, regex, true, isFile, resultFiles);
                        } catch (FileNotFoundException e) {
                                e.printStackTrace();
                        } catch (IOException e) {
index e407ab2..4124449 100644 (file)
@@ -239,7 +239,7 @@ public class AppInfo {
 
                // check debuginfo file path
                if (debugInfoRpmFile.getName().contains(RpmUtil.DEBUGINFO)) {
-                       List<String> files = FileUtil.findFilesInDir(rpmPath, getExecFileName() + ".debug");
+                       List<String> files = FileUtil.findFilesInDir(rpmPath, getExecFileName() + ".debug", true);
                        if (files.size() == 0) {
                                return;
                        } else {
@@ -248,7 +248,7 @@ public class AppInfo {
                        }
                        // future extension for applications with normal debug package
                } else if (debugInfoRpmFile.getName().contains(RpmUtil.DEBUG)) {
-                       List<String> files = FileUtil.findFilesInDir(rpmPath, getExecFileName());
+                       List<String> files = FileUtil.findFilesInDir(rpmPath, getExecFileName(), true);
                        if (files.size() == 0) {
                                return;
                        } else {
@@ -313,7 +313,7 @@ public class AppInfo {
 
                // check debugsource file path
                List<String> files = FileUtil.findFilesInDir(rpmPath, projectName
-                               + CommonConstants.ASTERISK);
+                               + CommonConstants.ASTERISK, false);
                if (files.size() != 0) {
                        setSourcePath(rpmPath);
                        Logger.debug("SOURCE PATH : " + properties.get(PROPERTY.SRCPATH.index));
index c6596e7..e0bc9c4 100644 (file)
@@ -212,7 +212,7 @@ public class BinarySettingManager {
                if (debugRpmPath.contains(RpmUtil.DEBUGINFO)) {
                        // find real debug file
                        String debugCandidate = "*" + binName + ".debug";
-                       List<String> debugfilelist = FileUtil.findFilesInDir(extractPath, debugCandidate);
+                       List<String> debugfilelist = FileUtil.findFilesInDir(extractPath, debugCandidate, true);
                        if (debugfilelist.size() > 0) {
                                binData.setDebugFilePath(debugfilelist.get(0));
 
@@ -228,7 +228,7 @@ public class BinarySettingManager {
                                binData.setDebugFilePath(null);
                        }
                } else if (debugRpmPath.contains(RpmUtil.DEBUG)) {
-                       List<String> debugfilelist = FileUtil.findFilesInDir(extractPath, binName);
+                       List<String> debugfilelist = FileUtil.findFilesInDir(extractPath, binName, true);
                        if (debugfilelist.size() > 0) {
                                binData.setDebugFilePath(debugfilelist.get(0));
                        } else {
@@ -263,7 +263,7 @@ public class BinarySettingManager {
                        rootPath = rootPath + File.separator;
                }
 
-               List<String> rpmlist = FileUtil.findFilesInDir(rootPath, token);
+               List<String> rpmlist = FileUtil.findFilesInDir(rootPath, token, true);
 
                if (binName != null) {
                        // get file list in rpm package and find target binary name