jung6717 / arduino

Automatically exported from code.google.com/p/arduino
0 stars 0 forks source link

Library compile routine tries to compile hidden (dot) files #209

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Using Arduino 18 on a machine running Ubuntu Karmic, I noticed that the
library complier picks up . files with an extension of .cpp (e.g.
.test.cpp) and tries to compile them.  By convention, these sorts of file
are used as temporary buffers for file editors, and I've seen them included
in libraries created by OS X users (who apparently didn't have this issue).
 I would expect these files to be ignored.

To reproduce the issue, put a file called .test.cpp in a user library
directory, with the words "test file" in it, then try to compile a sketch
with the library included.

One solution would be to modify the findFilesInFolder() function in
Compiler.java:

Compiler.java
584c584
<       if (file.getName().equals(".") || file.getName().equals(".."))
continue;

---
>       if (file.getName().startsWith(".")) continue;

So that it looks like this:

  static public ArrayList<File> findFilesInFolder(File folder, String
extension,
                                                  boolean recurse) {
    ArrayList<File> files = new ArrayList<File>();

    if (folder.listFiles() == null) return files;

    for (File file : folder.listFiles()) {
      if (file.getName().startsWith(".")) continue;

      if (file.getName().endsWith("." + extension))
        files.add(file);

      if (recurse && file.isDirectory()) {
        files.addAll(findFilesInFolder(file, extension, true));
      }
    }

    return files;
  }

Original issue reported on code.google.com by Matt.M...@gmail.com on 24 Feb 2010 at 12:56

GoogleCodeExporter commented 8 years ago
Good idea.

Original comment by dmel...@gmail.com on 24 Feb 2010 at 2:23

GoogleCodeExporter commented 8 years ago
Fixed, thanks.  r978

Original comment by dmel...@gmail.com on 13 Jun 2010 at 7:25