mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-01 13:25:45 +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.IProjectEntry;
|
||||||
import org.eclipse.cdt.core.model.ISourceEntry;
|
import org.eclipse.cdt.core.model.ISourceEntry;
|
||||||
import org.eclipse.cdt.core.resources.IPathEntryVariableManager;
|
import org.eclipse.cdt.core.resources.IPathEntryVariableManager;
|
||||||
|
import org.eclipse.cdt.utils.UNCPathConverter;
|
||||||
import org.eclipse.core.resources.IMarker;
|
import org.eclipse.core.resources.IMarker;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
|
@ -513,6 +514,9 @@ public class PathEntryUtil {
|
||||||
|
|
||||||
private static boolean isValidExternalPath(IPath path) {
|
private static boolean isValidExternalPath(IPath path) {
|
||||||
if (path != null) {
|
if (path != null) {
|
||||||
|
if (path.isUNC()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
File file = path.toFile();
|
File file = path.toFile();
|
||||||
if (file != null) {
|
if (file != null) {
|
||||||
return file.exists();
|
return file.exists();
|
||||||
|
|
|
@ -13,7 +13,6 @@ package org.eclipse.cdt.internal.core.parser;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
@ -159,26 +158,15 @@ public class InternalParserUtil extends ParserFactory {
|
||||||
IFileStore store = EFS.getStore(file.getLocationURI());
|
IFileStore store = EFS.getStore(file.getLocationURI());
|
||||||
IFileInfo fileInfo = store.fetchInfo();
|
IFileInfo fileInfo = store.fetchInfo();
|
||||||
input= file.getContents(true);
|
input= file.getContents(true);
|
||||||
if (!(input instanceof FileInputStream)) {
|
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);
|
|
||||||
try {
|
try {
|
||||||
input = new FileInputStream(fileCache);
|
return createFileContent(path, null, file.getCharset(), input,
|
||||||
} catch (FileNotFoundException e) {
|
fileInfo.getLastModified(), fileInfo.getLength(), fileReadTime);
|
||||||
CCorePlugin.log(e);
|
} finally {
|
||||||
return null;
|
try {
|
||||||
}
|
input.close();
|
||||||
}
|
} catch (IOException e) {
|
||||||
try {
|
}
|
||||||
return createFileContent(path, file.getCharset(), input,
|
|
||||||
fileInfo.getLastModified(), fileInfo.getLength(), fileReadTime);
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
input.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
|
@ -193,18 +181,19 @@ public class InternalParserUtil extends ParserFactory {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a code reader for an external location, normalizing path to
|
* Creates a code reader for an external location, normalizing path to
|
||||||
* canonical path.
|
* canonical path.
|
||||||
*/
|
*/
|
||||||
public static InternalFileContent createExternalFileContent(String externalLocation, String encoding) {
|
public static InternalFileContent createExternalFileContent(final String externalLocation, String encoding) {
|
||||||
long fileReadTime = System.currentTimeMillis();
|
long fileReadTime = System.currentTimeMillis();
|
||||||
File includeFile = null;
|
File includeFile = null;
|
||||||
String path = null;
|
String path = null;
|
||||||
|
String localPath = null;
|
||||||
if (!UNCPathConverter.isUNC(externalLocation)) {
|
if (!UNCPathConverter.isUNC(externalLocation)) {
|
||||||
includeFile = new File(externalLocation);
|
includeFile = new File(externalLocation);
|
||||||
// Use the canonical path so that in case of non-case-sensitive OSs
|
// 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));
|
IFileStore store = EFS.getStore(UNCPathConverter.getInstance().toURI(externalLocation));
|
||||||
includeFile = store.toLocalFile(EFS.CACHE, null);
|
includeFile = store.toLocalFile(EFS.CACHE, null);
|
||||||
path = externalLocation;
|
path = externalLocation;
|
||||||
|
localPath = includeFile.getAbsolutePath();
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -230,7 +220,7 @@ public class InternalParserUtil extends ParserFactory {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
return createFileContent(path, encoding, in, timestamp, fileSize, fileReadTime);
|
return createFileContent(path, localPath, encoding, in, timestamp, fileSize, fileReadTime);
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
in.close();
|
in.close();
|
||||||
|
@ -241,10 +231,13 @@ public class InternalParserUtil extends ParserFactory {
|
||||||
return null;
|
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) {
|
long fileTimestamp, long fileSize, long fileReadTime) {
|
||||||
|
if (localPath == null) {
|
||||||
|
localPath = path;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
AbstractCharArray chars= FileCharArray.create(path, charset, in);
|
AbstractCharArray chars= FileCharArray.create(localPath, charset, in);
|
||||||
if (chars == null)
|
if (chars == null)
|
||||||
return 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.index.IIndexFragmentFile;
|
||||||
import org.eclipse.cdt.internal.core.parser.IMacroDictionary;
|
import org.eclipse.cdt.internal.core.parser.IMacroDictionary;
|
||||||
import org.eclipse.cdt.internal.core.parser.scanner.InternalFileContent.InclusionKind;
|
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
|
* Internal implementation of the file content providers
|
||||||
|
@ -49,7 +53,16 @@ public abstract class InternalFileContentProvider extends IncludeFileContentProv
|
||||||
/**
|
/**
|
||||||
* Checks whether the specified inclusion exists.
|
* 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();
|
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.core.settings.model.util.CDataUtil;
|
||||||
import org.eclipse.cdt.ui.CDTSharedImages;
|
import org.eclipse.cdt.ui.CDTSharedImages;
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
|
import org.eclipse.cdt.utils.UNCPathConverter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper class to provide unified images for {@link ICLanguageSettingEntry}.
|
* Helper class to provide unified images for {@link ICLanguageSettingEntry}.
|
||||||
|
@ -168,6 +169,8 @@ public class LanguageSettingsImages {
|
||||||
IPath path = new Path(entry.getValue());
|
IPath path = new Path(entry.getValue());
|
||||||
IResource rc = ResourcesPlugin.getWorkspace().getRoot().findMember(path);
|
IResource rc = ResourcesPlugin.getWorkspace().getRoot().findMember(path);
|
||||||
exists = (rc !=null) && rc.isAccessible();
|
exists = (rc !=null) && rc.isAccessible();
|
||||||
|
} else if (UNCPathConverter.isUNC(entry.getName())) {
|
||||||
|
return true;
|
||||||
} else {
|
} else {
|
||||||
String pathname = entry.getName();
|
String pathname = entry.getName();
|
||||||
java.io.File file = new java.io.File(pathname);
|
java.io.File file = new java.io.File(pathname);
|
||||||
|
|
Loading…
Add table
Reference in a new issue