mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 09:46:02 +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.OperationCanceledException;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
import org.eclipse.core.runtime.Platform;
|
import org.eclipse.core.runtime.Platform;
|
||||||
|
import org.eclipse.core.runtime.content.*;
|
||||||
import org.eclipse.debug.core.DebugPlugin;
|
import org.eclipse.debug.core.DebugPlugin;
|
||||||
|
|
||||||
public class StandardExecutableImporter implements IExecutableImporter {
|
public class StandardExecutableImporter implements IExecutableImporter {
|
||||||
|
@ -141,8 +142,10 @@ public class StandardExecutableImporter implements IExecutableImporter {
|
||||||
String executableName = location.toFile().getName();
|
String executableName = location.toFile().getName();
|
||||||
try {
|
try {
|
||||||
IContainer fileContainer = createFromRoot(exeProject, location);
|
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))) {
|
if (!exeFile.exists() && validateBinaryParsers(exeProject, new File(path))) {
|
||||||
|
ensureBinaryType(exectuableFilePath);
|
||||||
exeFile.createLink(location, 0, null);
|
exeFile.createLink(location, 0, null);
|
||||||
}
|
}
|
||||||
} catch (CoreException e) {
|
} 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) {
|
private boolean isExtensionVisible(IExtension ext) {
|
||||||
IConfigurationElement[] elements = ext.getConfigurationElements();
|
IConfigurationElement[] elements = ext.getConfigurationElements();
|
||||||
for (int i = 0; i < elements.length; i++) {
|
for (int i = 0; i < elements.length; i++) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue