mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
This commit is contained in:
parent
93dfa55ecf
commit
70e5780f88
2 changed files with 22 additions and 20 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2004-04-19 David Inglis
|
||||||
|
Fixed https://bugs.eclipse.org/bugs/show_bug.cgi?id=58232
|
||||||
|
|
||||||
|
* src/org/eclipse/cdt/internal/core/CDescriptor.java
|
||||||
|
|
||||||
2004-04-18 Alain Magloire
|
2004-04-18 Alain Magloire
|
||||||
|
|
||||||
Added a new method in CoreModel to get ITranslationUnit
|
Added a new method in CoreModel to get ITranslationUnit
|
||||||
|
|
|
@ -11,9 +11,9 @@ package org.eclipse.cdt.internal.core;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
@ -156,12 +156,10 @@ public class CDescriptor implements ICDescriptor {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String readCDTProjectFile(IPath descriptionPath) throws CoreException {
|
private String readCDTProjectFile(IPath descriptionPath) throws CoreException {
|
||||||
FileInputStream file = null;
|
|
||||||
String ownerID = ""; //$NON-NLS-1$
|
String ownerID = ""; //$NON-NLS-1$
|
||||||
try {
|
try {
|
||||||
file = new FileInputStream(descriptionPath.toFile());
|
|
||||||
DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
|
DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
|
||||||
Document document = parser.parse(file);
|
Document document = parser.parse(descriptionPath.toFile());
|
||||||
NodeList nodeList = document.getElementsByTagName(PROJECT_DESCRIPTION);
|
NodeList nodeList = document.getElementsByTagName(PROJECT_DESCRIPTION);
|
||||||
if (nodeList != null && nodeList.getLength() > 0) {
|
if (nodeList != null && nodeList.getLength() > 0) {
|
||||||
Node node = nodeList.item(0);
|
Node node = nodeList.item(0);
|
||||||
|
@ -177,13 +175,6 @@ public class CDescriptor implements ICDescriptor {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
IStatus status = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, -1, e.toString(), e);
|
IStatus status = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, -1, e.toString(), e);
|
||||||
throw new CoreException(status);
|
throw new CoreException(status);
|
||||||
} finally {
|
|
||||||
if (file != null) {
|
|
||||||
try {
|
|
||||||
file.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -322,16 +313,21 @@ public class CDescriptor implements ICDescriptor {
|
||||||
}
|
}
|
||||||
|
|
||||||
IFile rscFile = getFile();
|
IFile rscFile = getFile();
|
||||||
InputStream inputStream = new ByteArrayInputStream(xml.getBytes());
|
InputStream inputStream;
|
||||||
// update the resource content
|
try {
|
||||||
if (rscFile.exists()) {
|
inputStream = new ByteArrayInputStream(xml.getBytes("UTF8")); //$NON-NLS-1$
|
||||||
if (rscFile.isReadOnly()) {
|
if (rscFile.exists()) {
|
||||||
// provide opportunity to checkout read-only .cdtproject file
|
if (rscFile.isReadOnly()) {
|
||||||
fManager.getWorkspace().validateEdit(new IFile[]{rscFile}, null);
|
// provide opportunity to checkout read-only .cdtproject file
|
||||||
|
fManager.getWorkspace().validateEdit(new IFile[]{rscFile}, null);
|
||||||
|
}
|
||||||
|
rscFile.setContents(inputStream, IResource.FORCE, null);
|
||||||
|
} else {
|
||||||
|
rscFile.create(inputStream, IResource.FORCE, null);
|
||||||
}
|
}
|
||||||
rscFile.setContents(inputStream, IResource.FORCE, null);
|
} catch (UnsupportedEncodingException e) {
|
||||||
} else {
|
IStatus s = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, -1, e.getMessage(), e);
|
||||||
rscFile.create(inputStream, IResource.FORCE, null);
|
throw new CoreException(s);
|
||||||
}
|
}
|
||||||
fUpdating = false;
|
fUpdating = false;
|
||||||
}
|
}
|
||||||
|
@ -588,6 +584,7 @@ public class CDescriptor implements ICDescriptor {
|
||||||
TransformerFactory factory = TransformerFactory.newInstance();
|
TransformerFactory factory = TransformerFactory.newInstance();
|
||||||
Transformer transformer = factory.newTransformer();
|
Transformer transformer = factory.newTransformer();
|
||||||
transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
|
transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
|
||||||
|
transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); //$NON-NLS-1$
|
||||||
transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
|
transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
|
||||||
|
|
||||||
DOMSource source = new DOMSource(doc);
|
DOMSource source = new DOMSource(doc);
|
||||||
|
|
Loading…
Add table
Reference in a new issue