|
Lines 13-18
Link Here
|
| 13 |
import java.io.File; |
13 |
import java.io.File; |
| 14 |
import java.io.FileInputStream; |
14 |
import java.io.FileInputStream; |
| 15 |
import java.io.FileNotFoundException; |
15 |
import java.io.FileNotFoundException; |
|
|
16 |
import java.io.IOException; |
| 16 |
import java.io.InputStream; |
17 |
import java.io.InputStream; |
| 17 |
import java.util.ArrayList; |
18 |
import java.util.ArrayList; |
| 18 |
import java.util.List; |
19 |
import java.util.List; |
|
Lines 47-59
Link Here
|
| 47 |
List result = new ArrayList(childrenLength); |
48 |
List result = new ArrayList(childrenLength); |
| 48 |
|
49 |
|
| 49 |
for (int i = 0; i < childrenLength; i++) { |
50 |
for (int i = 0; i < childrenLength; i++) { |
| 50 |
result.add(new File(folder, children[i])); |
51 |
File file = new File(folder, children[i]); |
|
|
52 |
if(hasCycles(file)) |
| 53 |
continue; |
| 54 |
result.add(file); |
| 51 |
} |
55 |
} |
| 52 |
|
56 |
|
| 53 |
return result; |
57 |
return result; |
| 54 |
} |
58 |
} |
| 55 |
|
59 |
|
| 56 |
/* (non-Javadoc) |
60 |
private boolean hasCycles(File file) { |
|
|
61 |
|
| 62 |
boolean hasCycles = false; |
| 63 |
try { |
| 64 |
String canonicalPath = file.getCanonicalPath(); |
| 65 |
String absolutePath = file.getAbsolutePath(); |
| 66 |
|
| 67 |
// if its not a symbolic link, then no cycles |
| 68 |
if(!canonicalPath.equals(absolutePath)){ |
| 69 |
|
| 70 |
File parentFile = file.getParentFile(); |
| 71 |
while(parentFile !=null){ |
| 72 |
|
| 73 |
String parentCanonicalPath = parentFile.getCanonicalPath(); |
| 74 |
if(canonicalPath.equals(parentCanonicalPath)){ |
| 75 |
hasCycles = true; |
| 76 |
break; |
| 77 |
} |
| 78 |
parentFile = parentFile.getParentFile(); |
| 79 |
} |
| 80 |
} |
| 81 |
} catch (IOException e) { |
| 82 |
IDEWorkbenchPlugin.log(e.getMessage(), e); |
| 83 |
} |
| 84 |
return hasCycles; |
| 85 |
} |
| 86 |
|
| 87 |
/* (non-Javadoc) |
| 57 |
* Method declared on IImportStructureProvider |
88 |
* Method declared on IImportStructureProvider |
| 58 |
*/ |
89 |
*/ |
| 59 |
public InputStream getContents(Object element) { |
90 |
public InputStream getContents(Object element) { |