Beispiel #1
0
 private bool FindBootClassPathFile(string name, CrcsProject project, string missingClassName)
 {
     foreach (string location in project.LocationsOfDependencies)
     {
         string[] files = Directory.GetFiles(location, missingClassName + ".smali", SearchOption.AllDirectories);
         if (files.Length > 0)
         {
             string folder = files[0].Substring(location.Length).TrimStart(Path.DirectorySeparatorChar).Substring(7).TrimStart(Path.DirectorySeparatorChar);
             folder = folder.Split(Path.DirectorySeparatorChar)[0];
             return(project.AddDependency(name, folder));
         }
     }
     return(false);
 }
Beispiel #2
0
        protected bool FindMissingDependency(string name, CrcsProject project, string baksmaliOutput)
        {
            string[] bootClassPathArray = GetBootClassPath(baksmaliOutput);
            if (bootClassPathArray.Length == 0)
            {
                return(false);
            }
            if (bootClassPathArray[0].Equals("junit", StringComparison.OrdinalIgnoreCase) &&
                project.LocationsOfDependencies.FirstOrDefault(x => File.Exists(Path.Combine(x, "core-junit.jar"))) !=
                null)
            {
                return(project.AddDependency(name, "core-junit.jar"));
            }

            string missingClassName = bootClassPathArray[bootClassPathArray.Length - 1];

            if (FindBootClassPathFile(name, project, missingClassName))
            {
                return(true);
            }

            int start = 0;
            int count = bootClassPathArray.Length - 1;

            while (count > 0)
            {
                string bootClassPath = string.Join(".", bootClassPathArray, start, count) + ".jar";
                if (project.LocationsOfDependencies.FirstOrDefault(x => File.Exists(Path.Combine(x, bootClassPath))) !=
                    null)
                {
                    return(project.AddDependency(name, bootClassPath));
                }
                start++;
                count--;
            }
            return(false);
        }