mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-05 00:36:16 +02:00
add file extension as binary content type if necessary when importing executables.
This commit is contained in:
parent
e552cc6d3a
commit
935103d5a5
1 changed files with 20 additions and 1 deletions
|
@ -39,6 +39,7 @@ import org.eclipse.core.runtime.NullProgressMonitor;
|
|||
import org.eclipse.core.runtime.OperationCanceledException;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.core.runtime.content.*;
|
||||
import org.eclipse.debug.core.DebugPlugin;
|
||||
|
||||
public class StandardExecutableImporter implements IExecutableImporter {
|
||||
|
@ -141,8 +142,10 @@ public class StandardExecutableImporter implements IExecutableImporter {
|
|||
String executableName = location.toFile().getName();
|
||||
try {
|
||||
IContainer fileContainer = createFromRoot(exeProject, location);
|
||||
IFile exeFile = fileContainer.getFile(new Path(executableName));
|
||||
Path exectuableFilePath = new Path(executableName);
|
||||
IFile exeFile = fileContainer.getFile(exectuableFilePath);
|
||||
if (!exeFile.exists() && validateBinaryParsers(exeProject, new File(path))) {
|
||||
ensureBinaryType(exectuableFilePath);
|
||||
exeFile.createLink(location, 0, null);
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
|
@ -150,6 +153,22 @@ public class StandardExecutableImporter implements IExecutableImporter {
|
|||
}
|
||||
}
|
||||
|
||||
private void ensureBinaryType(IPath exectuableFilePath) {
|
||||
if (Executable.isExecutableFile(exectuableFilePath))
|
||||
return;
|
||||
String ext = exectuableFilePath.getFileExtension();
|
||||
if (ext != null) {
|
||||
// add the extension to the content type manager as a binary
|
||||
final IContentTypeManager ctm = Platform.getContentTypeManager();
|
||||
final IContentType ctbin = ctm.getContentType(CCorePlugin.CONTENT_TYPE_BINARYFILE);
|
||||
try {
|
||||
ctbin.addFileSpec(ext, IContentTypeSettings.FILE_EXTENSION_SPEC);
|
||||
} catch (CoreException e) {
|
||||
CDebugCorePlugin.log(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isExtensionVisible(IExtension ext) {
|
||||
IConfigurationElement[] elements = ext.getConfigurationElements();
|
||||
for (int i = 0; i < elements.length; i++) {
|
||||
|
|
Loading…
Add table
Reference in a new issue