Lines 12-18
Link Here
|
12 |
|
12 |
|
13 |
import java.io.File; |
13 |
import java.io.File; |
14 |
import java.io.IOException; |
14 |
import java.io.IOException; |
15 |
import java.util.zip.ZipFile; |
|
|
16 |
|
15 |
|
17 |
import org.eclipse.jdt.core.compiler.CharOperation; |
16 |
import org.eclipse.jdt.core.compiler.CharOperation; |
18 |
import org.eclipse.jdt.internal.compiler.env.AccessRuleSet; |
17 |
import org.eclipse.jdt.internal.compiler.env.AccessRuleSet; |
Lines 39-44
Link Here
|
39 |
* @return a normalized path for file based classpath entries |
38 |
* @return a normalized path for file based classpath entries |
40 |
*/ |
39 |
*/ |
41 |
String normalizedPath(); |
40 |
String normalizedPath(); |
|
|
41 |
/** |
42 |
* Initialize the entry |
43 |
*/ |
44 |
void initialize() throws IOException; |
42 |
} |
45 |
} |
43 |
/* |
46 |
/* |
44 |
classPathNames is a collection is Strings representing the full path of each class path |
47 |
classPathNames is a collection is Strings representing the full path of each class path |
Lines 49-101
Link Here
|
49 |
this(classpathNames, initialFileNames, encoding, null); |
52 |
this(classpathNames, initialFileNames, encoding, null); |
50 |
} |
53 |
} |
51 |
public FileSystem(String[] classpathNames, String[] initialFileNames, String encoding, int[] classpathDirectoryModes) { |
54 |
public FileSystem(String[] classpathNames, String[] initialFileNames, String encoding, int[] classpathDirectoryModes) { |
52 |
int classpathSize = classpathNames.length; |
55 |
final int classpathSize = classpathNames.length; |
53 |
this.classpaths = new Classpath[classpathSize]; |
56 |
this.classpaths = new Classpath[classpathSize]; |
54 |
int problemsOccured = 0; |
57 |
int counter = 0; |
55 |
for (int i = 0; i < classpathSize; i++) { |
58 |
for (int i = 0; i < classpathSize; i++) { |
56 |
this.classpaths[i] = getClasspath(classpathNames[i], encoding, |
59 |
Classpath classpath = getClasspath(classpathNames[i], encoding, |
57 |
classpathDirectoryModes == null ? 0 |
60 |
classpathDirectoryModes == null ? 0 |
58 |
: classpathDirectoryModes[i], null); |
61 |
: classpathDirectoryModes[i], null); |
59 |
if (this.classpaths[i] == null) |
62 |
try { |
60 |
problemsOccured++; |
63 |
classpath.initialize(); |
|
|
64 |
this.classpaths[counter++] = classpath; |
65 |
} catch (IOException e) { |
66 |
// ignore |
67 |
} |
61 |
} |
68 |
} |
62 |
if (problemsOccured > 0) { |
69 |
if (counter != classpathSize) { |
63 |
Classpath[] newPaths = new Classpath[classpathSize - problemsOccured]; |
70 |
System.arraycopy(this.classpaths, 0, (this.classpaths = new Classpath[counter]), 0, counter); |
64 |
for (int i = 0, current = 0; i < classpathSize; i++) |
|
|
65 |
if (this.classpaths[i] != null) { |
66 |
newPaths[current] = this.classpaths[i]; |
67 |
} |
68 |
classpathSize = newPaths.length; |
69 |
this.classpaths = newPaths; |
70 |
} |
71 |
} |
71 |
initializeKnownFileNames(initialFileNames); |
72 |
initializeKnownFileNames(initialFileNames); |
72 |
} |
73 |
} |
73 |
FileSystem(Classpath[] classpaths, String[] initialFileNames) { |
74 |
FileSystem(Classpath[] paths, String[] initialFileNames) { |
74 |
this.classpaths = classpaths; |
75 |
final int length = paths.length; |
|
|
76 |
int counter = 0; |
77 |
this.classpaths = new FileSystem.Classpath[length]; |
78 |
for (int i = 0; i < length; i++) { |
79 |
final Classpath classpath = paths[i]; |
80 |
try { |
81 |
classpath.initialize(); |
82 |
this.classpaths[counter++] = classpath; |
83 |
} catch(IOException exception) { |
84 |
// ignore |
85 |
} |
86 |
} |
87 |
if (counter != length) { |
88 |
// should not happen |
89 |
System.arraycopy(this.classpaths, 0, (this.classpaths = new FileSystem.Classpath[counter]), 0, counter); |
90 |
} |
75 |
initializeKnownFileNames(initialFileNames); |
91 |
initializeKnownFileNames(initialFileNames); |
76 |
} |
92 |
} |
77 |
static Classpath getClasspath(String classpathName, String encoding, |
93 |
static Classpath getClasspath(String classpathName, String encoding, |
78 |
int classpathDirectoryMode, AccessRuleSet accessRuleSet) { |
94 |
int classpathDirectoryMode, AccessRuleSet accessRuleSet) { |
79 |
Classpath result = null; |
95 |
Classpath result = null; |
80 |
try { |
96 |
File file = new File(convertPathSeparators(classpathName)); |
81 |
File file = new File(convertPathSeparators(classpathName)); |
97 |
if (file.isDirectory()) { |
82 |
if (file.isDirectory()) { |
98 |
if (file.exists()) { |
83 |
if (file.exists()) { |
99 |
result = new ClasspathDirectory(file, encoding, |
84 |
result = new ClasspathDirectory(file, encoding, |
100 |
classpathDirectoryMode, accessRuleSet); |
85 |
classpathDirectoryMode, accessRuleSet); |
|
|
86 |
} |
87 |
} else { |
88 |
String lowercaseClasspathName = classpathName.toLowerCase(); |
89 |
if (lowercaseClasspathName.endsWith(SUFFIX_STRING_jar) |
90 |
|| lowercaseClasspathName.endsWith(SUFFIX_STRING_zip)) { |
91 |
result = new ClasspathJar(new ZipFile(file), true, |
92 |
accessRuleSet); |
93 |
// will throw an IOException if file does not exist |
94 |
} |
95 |
} |
96 |
} catch (IOException e) { |
97 |
// result = null; -- this is already the case |
98 |
} |
101 |
} |
|
|
102 |
} else { |
103 |
String lowercaseClasspathName = classpathName.toLowerCase(); |
104 |
if (lowercaseClasspathName.endsWith(SUFFIX_STRING_jar) |
105 |
|| lowercaseClasspathName.endsWith(SUFFIX_STRING_zip)) { |
106 |
result = new ClasspathJar(file, true, accessRuleSet); |
107 |
// will throw an IOException if file does not exist |
108 |
} |
109 |
} |
99 |
return result; |
110 |
return result; |
100 |
} |
111 |
} |
101 |
private void initializeKnownFileNames(String[] initialFileNames) { |
112 |
private void initializeKnownFileNames(String[] initialFileNames) { |
Lines 174-180
Link Here
|
174 |
return null; |
185 |
return null; |
175 |
} |
186 |
} |
176 |
public ClasspathJar getClasspathJar(File file) throws IOException { |
187 |
public ClasspathJar getClasspathJar(File file) throws IOException { |
177 |
return new ClasspathJar(new ZipFile(file), true, null); |
188 |
return new ClasspathJar(file, true, null); |
178 |
} |
189 |
} |
179 |
public boolean isPackage(char[][] compoundName, char[] packageName) { |
190 |
public boolean isPackage(char[][] compoundName, char[] packageName) { |
180 |
String qualifiedPackageName = new String(CharOperation.concatWith(compoundName, packageName, '/')); |
191 |
String qualifiedPackageName = new String(CharOperation.concatWith(compoundName, packageName, '/')); |