1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Bug 349730: Content for non-local files

This commit is contained in:
Greg Watson 2011-08-17 12:27:48 +02:00 committed by Markus Schorn
parent c17176f43c
commit ffca7f9d6b

View file

@ -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);