1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-09 18:56:02 +02:00

Bug 312666: Default filesystem on Mac is case insensitive.

This commit is contained in:
Markus Schorn 2010-06-22 11:40:39 +00:00
parent 2c2fd351e0
commit 4088b51a27
2 changed files with 19 additions and 4 deletions

View file

@ -38,8 +38,14 @@ public final class FileExistsCache {
public BitSet fIsFile;
}
private Reference<Map<String,Content>> fCache= null;
private final boolean fCaseInSensitive;
public FileExistsCache() {
this(CASE_INSENSITIVE);
}
public FileExistsCache(boolean caseInsensitive) {
fCaseInSensitive= caseInsensitive;
fCache= new SoftReference<Map<String,Content>>(new HashMap<String, Content>()); // before running out of memory the entire map will be thrown away.
}
@ -54,7 +60,7 @@ public final class FileExistsCache {
return false;
String name= file.getName();
if (CASE_INSENSITIVE)
if (fCaseInSensitive)
name= name.toUpperCase();
Content avail= getExistsCache().get(parent);
@ -64,7 +70,7 @@ public final class FileExistsCache {
avail= EMPTY_STRING_ARRAY;
}
else {
if (CASE_INSENSITIVE) {
if (fCaseInSensitive) {
for (int i = 0; i < files.length; i++) {
files[i]= files[i].toUpperCase();
}

View file

@ -35,6 +35,7 @@ import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.content.IContentType;
/**
@ -42,7 +43,9 @@ import org.eclipse.core.runtime.content.IContentType;
* @since 5.0
*/
public class ProjectIndexerInputAdapter extends IndexerInputAdapter {
private static final boolean CASE_INSENSITIVE_FILE_SYSTEM = new File("a").equals(new File("A")); //$NON-NLS-1$//$NON-NLS-2$
private static final AbstractLanguage[] NO_LANGUAGE = new AbstractLanguage[0];
private final ICProject fCProject;
private final HashMap<String, IIndexFileLocation> fIflCache;
private final FileExistsCache fExistsCache;
@ -59,7 +62,7 @@ public class ProjectIndexerInputAdapter extends IndexerInputAdapter {
fProjectPrefix= cproject.getProject().getFullPath().toString() + IPath.SEPARATOR;
if (useCache) {
fIflCache= new HashMap<String, IIndexFileLocation>();
fExistsCache= new FileExistsCache();
fExistsCache= new FileExistsCache(isCaseInsensitiveFileSystem());
} else {
fIflCache= null;
fExistsCache= null;
@ -74,6 +77,12 @@ public class ProjectIndexerInputAdapter extends IndexerInputAdapter {
}
}
private boolean isCaseInsensitiveFileSystem() {
if (Platform.OS_MACOSX.equals(Platform.getOS()))
return true;
return CASE_INSENSITIVE_FILE_SYSTEM;
}
@Override
public IIndexFileLocation resolveASTPath(String astPath) {
if (fIflCache == null) {