Skip to content

Commit 612ccd4

Browse files
committed
[#182] mbs.cross: default toolchain logic
- use modified date
1 parent fb3c556 commit 612ccd4

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

ilg.gnuarmeclipse.managedbuild.cross/src/ilg/gnuarmeclipse/managedbuild/cross/ui/DefaultPreferences.java

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,6 @@ public static String discoverBuildToolsPath() {
293293
*/
294294
private static String getLastToolchain(String folder, final String executableName) {
295295

296-
List<String> list = new ArrayList<String>();
297296
File local = new File(folder);
298297
if (!local.isDirectory()) {
299298
// System.out.println(folder + " not a folder");
@@ -320,19 +319,19 @@ public boolean accept(File dir, String name) {
320319
return null;
321320
}
322321

322+
IPath latestPath = null;
323+
long latestDate = 0;
324+
323325
for (int i = 0; i < files.length; ++i) {
324-
list.add(files[i].getName());
326+
IPath path = (new Path(files[i].getAbsolutePath())).append("bin").append(executableName);
327+
long date = path.toFile().lastModified();
328+
if (date > latestDate) {
329+
latestPath = (new Path(files[i].getAbsolutePath())).append("bin");
330+
latestDate = date;
331+
}
325332
}
326333

327-
// The sort criteria is the lexicographical order on folder name.
328-
Collections.sort(list);
329-
330-
// Get the last name in ordered list.
331-
String last = list.get(list.size() - 1);
332-
333-
// System.out.println(last);
334-
IPath path = (new Path(folder)).append(last).append("bin");
335-
return path.toString();
334+
return latestPath.toString();
336335
}
337336

338337
/**

0 commit comments

Comments
 (0)