summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Watson2011-08-17 06:27:48 (EDT)
committer Markus Schorn2011-08-17 06:27:48 (EDT)
commitffca7f9d6bc38f101c22a80acafea04f18c5119b (patch)
tree00e1c0a746dd081c414771de84d73ac6103ba08d
parentc17176f43ce1a8e10fb6f3a13101262256bd9f95 (diff)
downloadorg.eclipse.cdt-ffca7f9d6bc38f101c22a80acafea04f18c5119b.zip
org.eclipse.cdt-ffca7f9d6bc38f101c22a80acafea04f18c5119b.tar.gz
org.eclipse.cdt-ffca7f9d6bc38f101c22a80acafea04f18c5119b.tar.bz2
Bug 349730: Content for non-local files
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/InternalParserUtil.java18
1 files changed, 18 insertions, 0 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/InternalParserUtil.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/InternalParserUtil.java
index 76688c4..bc2f1d5 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/InternalParserUtil.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/InternalParserUtil.java
@@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.core.parser;
import java.io.File;
import java.io.FileInputStream;
+import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
@@ -154,6 +155,20 @@ public class InternalParserUtil extends ParserFactory {
InputStream in;
try {
in= file.getContents(true);
+ if (!(in instanceof FileInputStream)) {
+ /*
+ * In general, non-local file-systems will not use FileInputStream. Instead make a
+ * cached copy of the file and open an input stream to that.
+ */
+ IFileStore store = EFS.getStore(file.getLocationURI());
+ File fileCache = store.toLocalFile(EFS.CACHE, null);
+ try {
+ in = new FileInputStream(fileCache);
+ } catch (FileNotFoundException e) {
+ CCorePlugin.log(e);
+ return null;
+ }
+ }
try {
return createFileContent(path, file.getCharset(), in);
} finally {
@@ -221,6 +236,9 @@ public class InternalParserUtil extends ParserFactory {
private static InternalFileContent createFileContent(String path, String charset, InputStream in) {
try {
AbstractCharArray chars= FileCharArray.create(path, charset, in);
+ if (chars == null)
+ return null;
+
return new InternalFileContent(path, chars);
} catch (IOException e) {
CCorePlugin.log(e);