mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Improve binary detection for numeric extensions, related to bug 194194
This commit is contained in:
parent
1019868357
commit
c694ebe16c
1 changed files with 23 additions and 17 deletions
|
@ -80,6 +80,7 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.ISafeRunnable;
|
import org.eclipse.core.runtime.ISafeRunnable;
|
||||||
|
import org.eclipse.core.runtime.Path;
|
||||||
import org.eclipse.core.runtime.Platform;
|
import org.eclipse.core.runtime.Platform;
|
||||||
import org.eclipse.core.runtime.SafeRunner;
|
import org.eclipse.core.runtime.SafeRunner;
|
||||||
import org.eclipse.core.runtime.content.IContentType;
|
import org.eclipse.core.runtime.content.IContentType;
|
||||||
|
@ -641,25 +642,30 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
|
||||||
// Only if file has no extension, has an extension that is an integer
|
// Only if file has no extension, has an extension that is an integer
|
||||||
// or is a binary file content type
|
// or is a binary file content type
|
||||||
String ext = file.getFileExtension();
|
String ext = file.getFileExtension();
|
||||||
if (ext != null) {
|
if (ext != null && ext.length() > 0) {
|
||||||
// shared libraries often have a version number
|
// shared libraries often have a version number
|
||||||
boolean isNumber = true;
|
// strip version extension: libc.so.3.2.1 -> libc.so
|
||||||
for (int i = 0; i < ext.length(); ++i)
|
IPath baseFileName = new Path(file.getName());
|
||||||
if (!Character.isDigit(ext.charAt(i))) {
|
outer: do {
|
||||||
isNumber = false;
|
for (int i = 0; i < ext.length(); ++i) {
|
||||||
break;
|
if (!Character.isDigit(ext.charAt(i))) {
|
||||||
}
|
break outer;
|
||||||
if (!isNumber) {
|
}
|
||||||
boolean isBinary= false;
|
|
||||||
final IContentTypeManager ctm = Platform.getContentTypeManager();
|
|
||||||
final IContentType ctbin = ctm.getContentType(CCorePlugin.CONTENT_TYPE_BINARYFILE);
|
|
||||||
final IContentType[] cts= ctm.findContentTypesFor(file.getName());
|
|
||||||
for (int i=0; !isBinary && i < cts.length; i++) {
|
|
||||||
isBinary= cts[i].isKindOf(ctbin);
|
|
||||||
}
|
|
||||||
if (!isBinary) {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
// extension is a number -> remove it
|
||||||
|
baseFileName = baseFileName.removeFileExtension();
|
||||||
|
ext = baseFileName.getFileExtension();
|
||||||
|
} while (ext != null && ext.length() > 0);
|
||||||
|
|
||||||
|
boolean isBinary= false;
|
||||||
|
final IContentTypeManager ctm = Platform.getContentTypeManager();
|
||||||
|
final IContentType ctbin = ctm.getContentType(CCorePlugin.CONTENT_TYPE_BINARYFILE);
|
||||||
|
final IContentType[] cts= ctm.findContentTypesFor(baseFileName.toString());
|
||||||
|
for (int i=0; !isBinary && i < cts.length; i++) {
|
||||||
|
isBinary= cts[i].isKindOf(ctbin);
|
||||||
|
}
|
||||||
|
if (!isBinary) {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue