mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-30 20:35:38 +02:00
Bug 396651
Change-Id: If8ff6c840c82d1174c8cec79f9b038bd30267cb7 Reviewed-on: https://git.eclipse.org/r/9982 Reviewed-by: Sergey Prigogin <eclipse.sprigogin@gmail.com> IP-Clean: Sergey Prigogin <eclipse.sprigogin@gmail.com> Tested-by: Sergey Prigogin <eclipse.sprigogin@gmail.com>
This commit is contained in:
parent
2bc9035f8c
commit
f63c877df9
4 changed files with 39 additions and 26 deletions
|
@ -38,6 +38,7 @@ import org.eclipse.cdt.core.model.IPathEntryContainer;
|
|||
import org.eclipse.cdt.core.model.IProjectEntry;
|
||||
import org.eclipse.cdt.core.model.ISourceEntry;
|
||||
import org.eclipse.cdt.core.resources.IPathEntryVariableManager;
|
||||
import org.eclipse.cdt.utils.UNCPathConverter;
|
||||
import org.eclipse.core.resources.IMarker;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
|
@ -513,6 +514,9 @@ public class PathEntryUtil {
|
|||
|
||||
private static boolean isValidExternalPath(IPath path) {
|
||||
if (path != null) {
|
||||
if (path.isUNC()) {
|
||||
return true;
|
||||
}
|
||||
File file = path.toFile();
|
||||
if (file != null) {
|
||||
return file.exists();
|
||||
|
|
|
@ -13,7 +13,6 @@ 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;
|
||||
|
||||
|
@ -159,26 +158,15 @@ public class InternalParserUtil extends ParserFactory {
|
|||
IFileStore store = EFS.getStore(file.getLocationURI());
|
||||
IFileInfo fileInfo = store.fetchInfo();
|
||||
input= file.getContents(true);
|
||||
if (!(input 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.
|
||||
*/
|
||||
File fileCache = store.toLocalFile(EFS.CACHE, null);
|
||||
if (input instanceof FileInputStream) {
|
||||
try {
|
||||
input = new FileInputStream(fileCache);
|
||||
} catch (FileNotFoundException e) {
|
||||
CCorePlugin.log(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
try {
|
||||
return createFileContent(path, file.getCharset(), input,
|
||||
fileInfo.getLastModified(), fileInfo.getLength(), fileReadTime);
|
||||
} finally {
|
||||
try {
|
||||
input.close();
|
||||
} catch (IOException e) {
|
||||
return createFileContent(path, null, file.getCharset(), input,
|
||||
fileInfo.getLastModified(), fileInfo.getLength(), fileReadTime);
|
||||
} finally {
|
||||
try {
|
||||
input.close();
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
|
@ -193,18 +181,19 @@ public class InternalParserUtil extends ParserFactory {
|
|||
CCorePlugin.log(e);
|
||||
break;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a code reader for an external location, normalizing path to
|
||||
* canonical path.
|
||||
*/
|
||||
public static InternalFileContent createExternalFileContent(String externalLocation, String encoding) {
|
||||
public static InternalFileContent createExternalFileContent(final String externalLocation, String encoding) {
|
||||
long fileReadTime = System.currentTimeMillis();
|
||||
File includeFile = null;
|
||||
String path = null;
|
||||
String localPath = null;
|
||||
if (!UNCPathConverter.isUNC(externalLocation)) {
|
||||
includeFile = new File(externalLocation);
|
||||
// Use the canonical path so that in case of non-case-sensitive OSs
|
||||
|
@ -216,6 +205,7 @@ public class InternalParserUtil extends ParserFactory {
|
|||
IFileStore store = EFS.getStore(UNCPathConverter.getInstance().toURI(externalLocation));
|
||||
includeFile = store.toLocalFile(EFS.CACHE, null);
|
||||
path = externalLocation;
|
||||
localPath = includeFile.getAbsolutePath();
|
||||
} catch (CoreException e) {
|
||||
}
|
||||
}
|
||||
|
@ -230,7 +220,7 @@ public class InternalParserUtil extends ParserFactory {
|
|||
return null;
|
||||
}
|
||||
try {
|
||||
return createFileContent(path, encoding, in, timestamp, fileSize, fileReadTime);
|
||||
return createFileContent(path, localPath, encoding, in, timestamp, fileSize, fileReadTime);
|
||||
} finally {
|
||||
try {
|
||||
in.close();
|
||||
|
@ -241,10 +231,13 @@ public class InternalParserUtil extends ParserFactory {
|
|||
return null;
|
||||
}
|
||||
|
||||
private static InternalFileContent createFileContent(String path, String charset, InputStream in,
|
||||
private static InternalFileContent createFileContent(String path, String localPath, String charset, InputStream in,
|
||||
long fileTimestamp, long fileSize, long fileReadTime) {
|
||||
if (localPath == null) {
|
||||
localPath = path;
|
||||
}
|
||||
try {
|
||||
AbstractCharArray chars= FileCharArray.create(path, charset, in);
|
||||
AbstractCharArray chars= FileCharArray.create(localPath, charset, in);
|
||||
if (chars == null)
|
||||
return null;
|
||||
|
||||
|
|
|
@ -28,6 +28,10 @@ import org.eclipse.cdt.internal.core.dom.IIncludeFileResolutionHeuristics;
|
|||
import org.eclipse.cdt.internal.core.index.IIndexFragmentFile;
|
||||
import org.eclipse.cdt.internal.core.parser.IMacroDictionary;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner.InternalFileContent.InclusionKind;
|
||||
import org.eclipse.cdt.utils.UNCPathConverter;
|
||||
import org.eclipse.core.filesystem.EFS;
|
||||
import org.eclipse.core.filesystem.IFileStore;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
* Internal implementation of the file content providers
|
||||
|
@ -49,7 +53,16 @@ public abstract class InternalFileContentProvider extends IncludeFileContentProv
|
|||
/**
|
||||
* Checks whether the specified inclusion exists.
|
||||
*/
|
||||
public boolean getInclusionExists(String path) {
|
||||
public boolean getInclusionExists(final String path) {
|
||||
if (UNCPathConverter.isUNC(path)) {
|
||||
try {
|
||||
IFileStore store = EFS.getStore(UNCPathConverter.getInstance().toURI(path));
|
||||
return store.fetchInfo().exists();
|
||||
} catch (CoreException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return new File(path).exists();
|
||||
}
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.eclipse.cdt.core.settings.model.ICSettingEntry;
|
|||
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
|
||||
import org.eclipse.cdt.ui.CDTSharedImages;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
import org.eclipse.cdt.utils.UNCPathConverter;
|
||||
|
||||
/**
|
||||
* Helper class to provide unified images for {@link ICLanguageSettingEntry}.
|
||||
|
@ -168,6 +169,8 @@ public class LanguageSettingsImages {
|
|||
IPath path = new Path(entry.getValue());
|
||||
IResource rc = ResourcesPlugin.getWorkspace().getRoot().findMember(path);
|
||||
exists = (rc !=null) && rc.isAccessible();
|
||||
} else if (UNCPathConverter.isUNC(entry.getName())) {
|
||||
return true;
|
||||
} else {
|
||||
String pathname = entry.getName();
|
||||
java.io.File file = new java.io.File(pathname);
|
||||
|
|
Loading…
Add table
Reference in a new issue