1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00
David Inglis 2004-04-19 13:38:15 +00:00
parent 93dfa55ecf
commit 70e5780f88
2 changed files with 22 additions and 20 deletions

View file

@ -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
Added a new method in CoreModel to get ITranslationUnit

View file

@ -11,9 +11,9 @@ package org.eclipse.cdt.internal.core;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
@ -156,12 +156,10 @@ public class CDescriptor implements ICDescriptor {
}
private String readCDTProjectFile(IPath descriptionPath) throws CoreException {
FileInputStream file = null;
String ownerID = ""; //$NON-NLS-1$
try {
file = new FileInputStream(descriptionPath.toFile());
DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document document = parser.parse(file);
Document document = parser.parse(descriptionPath.toFile());
NodeList nodeList = document.getElementsByTagName(PROJECT_DESCRIPTION);
if (nodeList != null && nodeList.getLength() > 0) {
Node node = nodeList.item(0);
@ -177,13 +175,6 @@ public class CDescriptor implements ICDescriptor {
} catch (Exception e) {
IStatus status = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, -1, e.toString(), e);
throw new CoreException(status);
} finally {
if (file != null) {
try {
file.close();
} catch (IOException e) {
}
}
}
}
@ -322,8 +313,9 @@ public class CDescriptor implements ICDescriptor {
}
IFile rscFile = getFile();
InputStream inputStream = new ByteArrayInputStream(xml.getBytes());
// update the resource content
InputStream inputStream;
try {
inputStream = new ByteArrayInputStream(xml.getBytes("UTF8")); //$NON-NLS-1$
if (rscFile.exists()) {
if (rscFile.isReadOnly()) {
// provide opportunity to checkout read-only .cdtproject file
@ -333,6 +325,10 @@ public class CDescriptor implements ICDescriptor {
} else {
rscFile.create(inputStream, IResource.FORCE, null);
}
} catch (UnsupportedEncodingException e) {
IStatus s = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, -1, e.getMessage(), e);
throw new CoreException(s);
}
fUpdating = false;
}
}, fProject, IWorkspace.AVOID_UPDATE, null);
@ -588,6 +584,7 @@ public class CDescriptor implements ICDescriptor {
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer();
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$
DOMSource source = new DOMSource(doc);