diff --git a/arduino-core/src/processing/app/helpers/FileUtils.java b/arduino-core/src/processing/app/helpers/FileUtils.java index 4f99f48e2..9d138b841 100644 --- a/arduino-core/src/processing/app/helpers/FileUtils.java +++ b/arduino-core/src/processing/app/helpers/FileUtils.java @@ -169,7 +169,15 @@ public class FileUtils { } public static boolean isSCCSOrHiddenFile(File file) { - return file.isHidden() || file.getName().charAt(0) == '.' || (file.isDirectory() && SOURCE_CONTROL_FOLDERS.contains(file.getName())); + return isSCCSFolder(file) || isHiddenFile(file); + } + + public static boolean isHiddenFile(File file) { + return file.isHidden() || file.getName().charAt(0) == '.'; + } + + public static boolean isSCCSFolder(File file) { + return file.isDirectory() && SOURCE_CONTROL_FOLDERS.contains(file.getName()); } public static String readFileToString(File file) throws IOException { diff --git a/arduino-core/src/processing/app/packages/UserLibrary.java b/arduino-core/src/processing/app/packages/UserLibrary.java index 941da7ad2..ef24022ab 100644 --- a/arduino-core/src/processing/app/packages/UserLibrary.java +++ b/arduino-core/src/processing/app/packages/UserLibrary.java @@ -83,8 +83,7 @@ public class UserLibrary extends ContributedLibrary { // "arch" folder no longer supported File archFolder = new File(libFolder, "arch"); if (archFolder.isDirectory()) - throw new IOException("'arch' folder is no longer supported! See " - + "http://goo.gl/gfFJzU for more information"); + throw new IOException("'arch' folder is no longer supported! See http://goo.gl/gfFJzU for more information"); // Check mandatory properties for (String p : MANDATORY_PROPERTIES) @@ -101,8 +100,7 @@ public class UserLibrary extends ContributedLibrary { File utilFolder = new File(libFolder, "utility"); if (utilFolder.exists() && utilFolder.isDirectory()) { - throw new IOException( - "Library can't use both 'src' and 'utility' folders."); + throw new IOException("Library can't use both 'src' and 'utility' folders."); } } else { // Layout with source code on library's root and "utility" folders @@ -110,11 +108,14 @@ public class UserLibrary extends ContributedLibrary { } // Warn if root folder contains development leftovers - for (File file : libFolder.listFiles()) { - if (file.isDirectory()) { - if (FileUtils.isSCCSOrHiddenFile(file)) { + File[] files = libFolder.listFiles(); + if (files == null) { + throw new IOException("Unable to list files of library in " + libFolder); + } + for (File file : files) { + if (file.isDirectory() && FileUtils.isSCCSOrHiddenFile(file)) { + if (!FileUtils.isSCCSFolder(file) && FileUtils.isHiddenFile(file)) { System.out.println("WARNING: Spurious " + file.getName() + " folder in '" + properties.get("name") + "' library"); - continue; } } } @@ -131,8 +132,7 @@ public class UserLibrary extends ContributedLibrary { if (category == null) category = "Uncategorized"; if (!CATEGORIES.contains(category)) { - System.out.println("WARNING: Category '" + category + "' in library " + - properties.get("name") + " is not valid. Setting to 'Uncategorized'"); + System.out.println("WARNING: Category '" + category + "' in library " + properties.get("name") + " is not valid. Setting to 'Uncategorized'"); category = "Uncategorized"; }