Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public Object[] findSourceElements(String name) throws CoreException {
if (fRootFile != null) {
// See bug 98090 - we need to handle relative path names
IFileStore target = fRootFile.getFileStore(IPath.fromOSString(name));
if (target.fetchInfo().exists()) {
if (target.exists()) {
// We no longer have to account for bug 95832, and URIs take care
// of canonical paths (fix to bug 95679 was removed).
IFile[] files = fRoot.findFilesForLocationURI(target.toURI());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ public void delete() throws CoreException {
IFileStore store = getFileStore();
if (store != null) {
store.delete(EFS.NONE, null);
if ((store.fetchInfo().exists())) {
if (store.exists()) {
throw new DebugException(
new Status(IStatus.ERROR, DebugPlugin.getUniqueIdentifier(),
DebugException.REQUEST_FAILED, DebugCoreMessages.LaunchConfiguration_Failed_to_delete_launch_configuration__1, null)
Expand Down Expand Up @@ -391,7 +391,7 @@ public boolean exists() {
try {
IFileStore store = getFileStore();
if (store != null) {
return store.fetchInfo().exists();
return store.exists();
}
} catch (CoreException e) {
}
Expand Down Expand Up @@ -870,7 +870,7 @@ public boolean isReadOnly() {
try {
IFileStore fileStore = getFileStore();
if (fileStore != null) {
return fileStore.fetchInfo().getAttribute(EFS.ATTRIBUTE_READ_ONLY);
return fileStore.fetchInfo(EFS.IGNORE_NAME_CASE, null).getAttribute(EFS.ATTRIBUTE_READ_ONLY);
}
} catch (CoreException e) {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ protected void writeNewFile(IProgressMonitor monitor) throws CoreException {
}
IFileStore dir = file.getParent();
dir.mkdir(EFS.SHALLOW, null);
if (!file.fetchInfo().exists()) {
if (!file.exists()) {
added = true;
updateMonitor(lmonitor, 1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public IFileStore mkdir(int options, IProgressMonitor monitor) throws CoreExcept
}
} else {
IFileStore parent = getParent();
if (parent.fetchInfo().exists()) {
if (parent.exists()) {
DebugFileSystem.getDefault().setContents(toURI(), DebugFileSystem.DIRECTORY_BYTES);
} else if ((options & EFS.SHALLOW) > 0) {
throw new CoreException(new Status(IStatus.ERROR, "org.eclipse.jdt.debug.tests", //$NON-NLS-1$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Since 3.3 you can use the new EFS support to open an text editor on a file outsi
return;
IFileStore fileStore = EFS.getLocalFileSystem().getStore(new Path(filterPath));
fileStore = fileStore.getChild(names[i]);
if (!fileStore.fetchInfo().isDirectory() && fileStore.fetchInfo().exists()) {
if (!fileStore.isDirectory() && fileStore.exists()) {
IWorkbenchPage page= window.getActivePage();
try {
IDE.openEditorOnFileStore(page, fileStore);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2005, 2013 IBM Corporation and others.
* Copyright (c) 2005, 2026 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -105,6 +105,17 @@ public class EFS {
*/
public static final int CACHE = 1 << 12;

/**
* Option flag constant (value 1 &lt;&lt;13) indicating that
* the exact casing of a file's name does not need to be determined.
* <p>
* For case-insensitive file-systems, like on Windows, this can accelerate fetching file information.
* </p>
* @see IFileStore#fetchInfo(int, IProgressMonitor)
* @since 1.12
*/
public static final int IGNORE_NAME_CASE = 1 << 13;

/**
* Attribute constant (value 1 &lt;&lt;1) indicating that a
* file is read only.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2005, 2015 IBM Corporation and others.
* Copyright (c) 2005, 2026 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -210,9 +210,14 @@ public interface IFileStore extends IAdaptable {
* file, the returned info will include the file's name and will return <code>false</code>
* when IFileInfo#exists() is called, but all other information will assume default
* values.
* </p>
* <p>
* The {@link EFS#IGNORE_NAME_CASE} option flag indicates if
* the casing of this file's name on the file-system is determined or not.
* This is only relevant for case-insensitive file-systems, but can accelerate the fetch.
* </p>
*
* @param options bit-wise or of option flag constants (currently only {@link EFS#NONE}
* is applicable).
* @param options bit-wise or of option flag constants ({@link EFS#NONE} or {@link EFS#IGNORE_NAME_CASE}).
* @param monitor a progress monitor, or <code>null</code> if progress
* reporting and cancellation are not desired
* @return A structure containing information about this file.
Expand All @@ -221,9 +226,38 @@ public interface IFileStore extends IAdaptable {
* <li>Problems occurred while contacting the file system.</li>
* </ul>
* @see IFileTree#getFileInfo(IFileStore)
* @see EFS#IGNORE_NAME_CASE
*/
public IFileInfo fetchInfo(int options, IProgressMonitor monitor) throws CoreException;

/**
* Returns whether this file or directory exists in the underlying file system.
*
* @return {@code true} if this file exists, and {@code false} if the file does not exist or an I/O error was encountered.
* @since 1.12
*/
public default boolean exists() {
try {
return fetchInfo(EFS.IGNORE_NAME_CASE, null).exists();
} catch (CoreException e) {
return false;
}
}

/**
* Returns whether this file is a directory, or {@code false} if this file does not exist.
*
* @return {@code true} if this is an existing directory, and {@code false} otherwise.
* @since 1.12
*/
public default boolean isDirectory() {
try {
return fetchInfo(EFS.IGNORE_NAME_CASE, null).isDirectory();
} catch (CoreException e) {
return false;
}
}

/**
* Returns a child of this store as specified by the provided path. The
* path is treated as relative to this store. This is equivalent to
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2005, 2024 IBM Corporation and others.
* Copyright (c) 2005, 2026 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -95,7 +95,7 @@ public IFileStore[] childStores(int options, IProgressMonitor monitor) throws Co
*/
@Override
public void copy(IFileStore destination, int options, IProgressMonitor monitor) throws CoreException {
final IFileInfo sourceInfo = fetchInfo(EFS.NONE, null);
final IFileInfo sourceInfo = fetchInfo(EFS.IGNORE_NAME_CASE, null);
if (sourceInfo.isDirectory()) {
copyDirectory(sourceInfo, destination, options, monitor);
} else {
Expand Down Expand Up @@ -161,7 +161,7 @@ protected void copyDirectory(IFileInfo sourceInfo, IFileStore destination, int o
* </ul>
*/
protected void copyFile(IFileInfo sourceInfo, IFileStore destination, int options, IProgressMonitor monitor) throws CoreException {
if ((options & EFS.OVERWRITE) == 0 && destination.fetchInfo().exists()) {
if ((options & EFS.OVERWRITE) == 0 && destination.exists()) {
Policy.error(EFS.ERROR_EXISTS, NLS.bind(Messages.fileExists, destination));
}
String sourcePath = toString();
Expand All @@ -178,7 +178,7 @@ protected void copyFile(IFileInfo sourceInfo, IFileStore destination, int option
Policy.error(EFS.ERROR_WRITE, NLS.bind(Messages.failedCopy, sourcePath), e);
} catch (CoreException e) {
//if we failed to write, try to cleanup the half written file
if (!destination.fetchInfo(0, null).exists()) {
if (!destination.fetchInfo(EFS.IGNORE_NAME_CASE, null).exists()) {
destination.delete(EFS.NONE, null);
}
throw e;
Expand Down Expand Up @@ -236,9 +236,7 @@ public IFileInfo fetchInfo() {
return fetchInfo(EFS.NONE, null);
} catch (CoreException e) {
//there was an error contacting the file system, so treat it as non-existent file
FileInfo result = new FileInfo(getName());
result.setExists(false);
return result;
return new FileInfo(getName());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,15 @@

import java.io.File;
import java.io.IOException;
import org.eclipse.core.filesystem.*;
import org.eclipse.core.filesystem.EFS;
import org.eclipse.core.filesystem.IFileInfo;
import org.eclipse.core.filesystem.IFileStore;
import org.eclipse.core.filesystem.provider.FileStore;
import org.eclipse.core.internal.filesystem.local.LocalFile;
import org.eclipse.core.runtime.*;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.osgi.service.environment.Constants;
import org.eclipse.osgi.util.NLS;

Expand Down Expand Up @@ -93,7 +98,7 @@ public static FileCache getCache() throws CoreException {
public java.io.File cache(IFileStore source, IProgressMonitor monitor) throws CoreException {
try {
SubMonitor subMonitor = SubMonitor.convert(monitor, NLS.bind(Messages.copying, toString()), 3);
IFileInfo myInfo = source.fetchInfo(EFS.NONE, subMonitor.newChild(1));
IFileInfo myInfo = source.fetchInfo(EFS.IGNORE_NAME_CASE, subMonitor.newChild(1));
if (!myInfo.exists()) {
return new File(cacheDir, "Non-Existent-" + System.currentTimeMillis()); //$NON-NLS-1$
}
Expand Down Expand Up @@ -141,7 +146,7 @@ private void clearImmutableFlag(File target) {
} else {
LocalFile lfile = new LocalFile(target);
try {
IFileInfo info = lfile.fetchInfo(EFS.NONE, null);
IFileInfo info = lfile.fetchInfo(EFS.IGNORE_NAME_CASE, null);
if (info.getAttribute(EFS.ATTRIBUTE_IMMUTABLE)) {
info.setAttribute(EFS.ATTRIBUTE_IMMUTABLE, false);
lfile.putInfo(info, EFS.SET_ATTRIBUTES, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ public class Convert {
/** Indicates the default native encoding on this platform */
private static String defaultEncoding = Platform.getSystemCharset().name();

public static final String WIN32_RAW_PATH_PREFIX = "\\\\?\\"; //$NON-NLS-1$
public static final String WIN32_UNC_RAW_PATH_PREFIX = "\\\\?\\UNC"; //$NON-NLS-1$

/**
* Calling new String(byte[] s) creates a new encoding object and other garbage.
* This can be avoided by calling new String(byte[] s, String encoding) instead.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2005, 2024 IBM Corporation and others.
* Copyright (c) 2005, 2026 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -232,7 +232,7 @@ public boolean equals(Object obj) {

@Override
public IFileInfo fetchInfo(int options, IProgressMonitor monitor) {
FileInfo info = LocalFileNativesManager.fetchFileInfo(filePath);
FileInfo info = LocalFileNativesManager.fetchFileInfo(filePath, options);
//natives don't set the file name on all platforms
if (info.getName().isEmpty()) {
String name = file.getName();
Expand Down Expand Up @@ -376,7 +376,7 @@ private IStatus internalDelete(File target, InfiniteProgress infMonitor, Executo
}

// If we got this far, we failed.
String message = fetchInfo().getAttribute(EFS.ATTRIBUTE_READ_ONLY) //
String message = fetchInfo(EFS.IGNORE_NAME_CASE, null).getAttribute(EFS.ATTRIBUTE_READ_ONLY) //
? Messages.couldnotDeleteReadOnly

// This is the worst-case scenario: something failed but we don't know what. The children were
Expand Down Expand Up @@ -499,7 +499,7 @@ public void move(IFileStore destFile, int options, IProgressMonitor monitor) thr
// source exists but destination doesn't so try to copy below
} else {
// destination.exists() returns false for broken links, this has to be handled explicitly
if (!destination.exists() && !destFile.fetchInfo().getAttribute(EFS.ATTRIBUTE_SYMLINK)) {
if (!destination.exists() && !destFile.fetchInfo(EFS.IGNORE_NAME_CASE, null).getAttribute(EFS.ATTRIBUTE_SYMLINK)) {
// neither the source nor the destination exist. this is REALLY bad
String message = NLS.bind(Messages.failedMove, source.getAbsolutePath(), destination.getAbsolutePath());
Policy.error(EFS.ERROR_WRITE, message);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2010, 2016 IBM Corporation and others.
* Copyright (c) 2010, 2026 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -88,8 +88,8 @@ public static int getSupportedAttributes() {
return HANDLER.getSupportedAttributes();
}

public static FileInfo fetchFileInfo(String fileName) {
return HANDLER.fetchFileInfo(fileName);
public static FileInfo fetchFileInfo(String fileName, int options) {
return HANDLER.fetchFileInfo(fileName, options);
}

public static boolean putFileInfo(String fileName, IFileInfo info, int options) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2012 IBM Corporation and others.
* Copyright (c) 2012, 2026 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand All @@ -14,6 +14,7 @@
package org.eclipse.core.internal.filesystem.local;

import java.io.File;
import org.eclipse.core.filesystem.EFS;
import org.eclipse.core.filesystem.IFileInfo;
import org.eclipse.core.filesystem.provider.FileInfo;

Expand All @@ -23,7 +24,7 @@
public abstract class NativeHandler {
public abstract int getSupportedAttributes();

public abstract FileInfo fetchFileInfo(String fileName);
public abstract FileInfo fetchFileInfo(String fileName, int options);

public abstract boolean putFileInfo(String fileName, IFileInfo info, int options);

Expand All @@ -38,7 +39,7 @@ public IFileInfo[] listDirectoryAndGetFileInfos(String fileName) {
var directoryContents = listDirectoryNames(fileName);
var result = new IFileInfo[directoryContents.length];
for (int i = 0; i < directoryContents.length; i++) {
result[i] = fetchFileInfo(fileName + File.separator + directoryContents[i]);
result[i] = fetchFileInfo(fileName + File.separator + directoryContents[i], EFS.NONE);
}
return result;
}
Expand Down
Loading
Loading