Skip to content
This repository has been archived by the owner on Apr 10, 2021. It is now read-only.

Commit

Permalink
fixed issue #59
Browse files Browse the repository at this point in the history
  • Loading branch information
Yserz committed Mar 23, 2015
1 parent 05017fc commit efe999c
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/main/java/org/editorconfig/core/EditorConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,16 @@ public List<OutPair> getProperties(String filePath) throws EditorConfigException
String dir = new File(filePath).getParent();
while (dir != null && !root) {
String configPath = dir + "/" + configFilename;

/**
* allows .../*.editorconfig files
*/
for (File file : new File(dir).listFiles()) {
if (getFileExtension(file).equals(configFilename)) {
configPath = file.getAbsolutePath();
}
}

if (new File(configPath).exists()) {
FileInputStream stream = new FileInputStream(configPath);
InputStreamReader reader = new InputStreamReader(stream, "UTF-8");
Expand Down Expand Up @@ -115,6 +125,15 @@ public List<OutPair> getProperties(String filePath) throws EditorConfigException
return result;
}

private String getFileExtension(File file) {
String name = file.getName();
int lastIndexOf = name.lastIndexOf(".");
if (lastIndexOf == -1) {
return ""; // empty extension
}
return name.substring(lastIndexOf);
}

private void checkAssertions() throws VersionException {
if (compareVersions(version, VERSION) > 0) {
throw new VersionException("Required version is greater than the current version.");
Expand Down

0 comments on commit efe999c

Please sign in to comment.