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
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, 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 @@ -224,6 +224,26 @@ public interface IFileStore extends IAdaptable {
*/
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() {
return fetchInfo().exists();
}

/**
* 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() {
return fetchInfo().isDirectory();
}

/**
* 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 @@ -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 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 @@ -44,7 +44,7 @@ public class BlobStore {
public BlobStore(IFileStore store, int limit) {
Assert.isNotNull(store);
localStore = store;
Assert.isTrue(localStore.fetchInfo().isDirectory());
Assert.isTrue(localStore.isDirectory());
Assert.isTrue(limit == 256 || limit == 128 || limit == 64 || limit == 32 || limit == 16 || limit == 8 || limit == 4 || limit == 2 || limit == 1);
mask = (byte) (limit - 1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ public void copy(IResource target, IResource destination, int updateFlags, IProg

SubMonitor subMonitor = SubMonitor.convert(monitor, title, 100);
IFileStore destinationStore = getStore(destination);
if (destinationStore.fetchInfo().exists()) {
if (destinationStore.exists()) {
String message = NLS.bind(Messages.localstore_resourceExists, destination.getFullPath());
throw new ResourceException(IResourceStatus.FAILED_WRITE_LOCAL, destination.getFullPath(), message, null);
}
Expand Down Expand Up @@ -575,7 +575,7 @@ public IFile fileForLocation(IPath location) {
public int getEncoding(File target) throws CoreException {
// thread safety: (the location can be null if the project for this file does not exist)
IFileStore store = getStore(target);
if (!store.fetchInfo().exists()) {
if (!store.exists()) {
String message = NLS.bind(Messages.localstore_fileNotFound, store.toString());
throw new ResourceException(IResourceStatus.FAILED_READ_LOCAL, target.getFullPath(), message, null);
}
Expand Down Expand Up @@ -675,7 +675,7 @@ protected Workspace getWorkspace() {
* Returns whether the project has any local content on disk.
*/
public boolean hasSavedContent(IProject project) {
return getStore(project).fetchInfo().exists();
return getStore(project).exists();
}

/**
Expand All @@ -684,8 +684,8 @@ public boolean hasSavedContent(IProject project) {
public boolean hasSavedDescription(IProject project) {
IResource dotProjectResource = project.getFile(IProjectDescription.DESCRIPTION_FILE_NAME);
return dotProjectResource.exists() ? //
getStore(dotProjectResource).fetchInfo().exists() : //
getStore(project).getChild(IProjectDescription.DESCRIPTION_FILE_NAME).fetchInfo().exists();
getStore(dotProjectResource).exists() : //
getStore(project).getChild(IProjectDescription.DESCRIPTION_FILE_NAME).exists();
}

/**
Expand Down Expand Up @@ -1017,7 +1017,7 @@ public ProjectDescription read(IProject target, boolean creation) throws CoreExc
if (description != null) {
return description;
}
if (!descriptionStore.fetchInfo().exists()) {
if (!descriptionStore.exists()) {
String msg = NLS.bind(Messages.resources_missingProjectMeta, target.getName());
throw new ResourceException(IResourceStatus.FAILED_READ_METADATA, target.getFullPath(), msg, null);
}
Expand Down Expand Up @@ -1381,8 +1381,7 @@ && storeHistory(target)) {
}
if (!assumeParentDirectoryExists && !fileInfo.exists()) {
IFileStore parent = store.getParent();
IFileInfo parentInfo = parent.fetchInfo();
if (!parentInfo.exists()) {
if (!parent.exists()) {
parent.mkdir(EFS.NONE, null);
}
}
Expand Down Expand Up @@ -1436,8 +1435,7 @@ public void write(IFile target, byte[] content, IFileInfo fileInfo, int updateFl
throw e;
}
IFileStore parent = store.getParent();
IFileInfo parentInfo = parent.fetchInfo();
if (parentInfo.exists()) {
if (parent.exists()) {
throw e;
}
// create missing folders:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ public synchronized void copyHistory(IResource sourceResource, IResource destina

@Override
public boolean exists(IFileState target) {
return blobStore.fileFor(((FileState) target).getUUID()).fetchInfo().exists();
return blobStore.fileFor(((FileState) target).getUUID()).exists();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ protected void deleteResource(UnifiedTreeNode node, Resource target) throws Core
IResource[] aliases = workspace.getAliasManager().computeAliases(target, store);
if (aliases != null) {
boolean wasFilteredOut = false;
if (store.fetchInfo() != null && store.fetchInfo().exists()) {
if (store.exists()) {
wasFilteredOut = target.isFiltered();
}
for (IResource aliase : aliases) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,15 @@
import org.eclipse.core.internal.resources.Resource;
import org.eclipse.core.internal.utils.Messages;
import org.eclipse.core.internal.utils.Policy;
import org.eclipse.core.resources.*;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.resources.refresh.IRefreshMonitor;
import org.eclipse.core.runtime.*;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.osgi.framework.Bundle;

Expand Down Expand Up @@ -192,7 +198,7 @@ private void poll(IResource resource) {
return;
}
//don't refresh links with no local content
if (resource.isLinked() && !((Resource) resource).getStore().fetchInfo().exists()) {
if (resource.isLinked() && !((Resource) resource).getStore().exists()) {
return;
}
//submit refresh request
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ private void buildLocationsMap() {
* @exception CoreException
*/
private boolean checkDeletion(Project project, IFileStore location) throws CoreException {
if (project.exists() && !location.fetchInfo().exists()) {
if (project.exists() && !location.exists()) {
//perform internal deletion of project from workspace tree because
// it is already deleted from disk and we can't acquire a different
//scheduling rule in this context (none is needed because we are
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import java.util.Map;
import java.util.TreeSet;
import org.eclipse.core.filesystem.EFS;
import org.eclipse.core.filesystem.IFileInfo;
import org.eclipse.core.filesystem.IFileStore;
import org.eclipse.core.internal.events.LifecycleEvent;
import org.eclipse.core.internal.preferences.EclipsePreferences;
Expand Down Expand Up @@ -100,8 +99,7 @@ protected void assertCreateRequirements(IProjectDescription description) throws
//if the project is in the default location, need to check for collision with existing folder of different case
if (!Workspace.caseSensitive) {
IFileStore store = getStore();
IFileInfo localInfo = store.fetchInfo();
if (localInfo.exists()) {
if (store.exists()) {
String name = getLocalManager().getLocalName(store);
if (name != null && !store.getName().equals(name)) {
String msg = NLS.bind(Messages.resources_existsLocalDifferentCase, IPath.fromOSString(store.toString()).removeLastSegments(1).append(name).toOSString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,35 @@
package org.eclipse.core.internal.resources;

import java.net.URI;
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.IFileSystem;
import org.eclipse.core.filesystem.URIUtil;
import org.eclipse.core.internal.localstore.FileSystemResourceManager;
import org.eclipse.core.internal.properties.IPropertyManager;
import org.eclipse.core.internal.utils.*;
import org.eclipse.core.resources.*;
import org.eclipse.core.internal.utils.BitMask;
import org.eclipse.core.internal.utils.Messages;
import org.eclipse.core.internal.utils.Policy;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceStatus;
import org.eclipse.core.resources.IResourceVisitor;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.resources.team.IResourceTree;
import org.eclipse.core.runtime.*;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.core.runtime.jobs.ILock;
import org.eclipse.osgi.util.NLS;

Expand Down Expand Up @@ -201,7 +222,7 @@ public void deletedProject(IProject target) {
private boolean ensureDestinationEmpty(IProject source, IFileStore destinationStore, IProgressMonitor monitor) throws CoreException {
String message;
//Make sure the destination location is unoccupied
if (!destinationStore.fetchInfo().exists()) {
if (!destinationStore.exists()) {
return true;
}
//check for existing children
Expand Down Expand Up @@ -289,7 +310,7 @@ private boolean internalDeleteFile(IFile file, int flags, IProgressMonitor monit
// If the file doesn't exist on disk then signal to the workspace to delete the
// file and return.
IFileStore fileStore = localManager.getStore(file);
boolean localExists = fileStore.fetchInfo().exists();
boolean localExists = fileStore.exists();
if (!localExists) {
deletedFile(file);
// Indicate that the delete was successful.
Expand Down Expand Up @@ -363,7 +384,7 @@ private boolean internalDeleteFolder(IFolder folder, int flags, IProgressMonitor

// If the folder doesn't exist on disk then update the tree and return.
IFileStore fileStore = localManager.getStore(folder);
if (!fileStore.fetchInfo().exists()) {
if (!fileStore.exists()) {
deletedFolder(folder);
return true;
}
Expand Down Expand Up @@ -970,7 +991,7 @@ public void standardMoveFile(IFile source, IFile destination, int flags, IProgre
} catch (CoreException e) {
failed(e.getStatus());
// did the fail occur after copying to the destination?
failedDeletingSource = destStore != null && destStore.fetchInfo().exists();
failedDeletingSource = destStore != null && destStore.exists();
// if so, we should proceed
if (!failedDeletingSource) {
return;
Expand Down Expand Up @@ -1039,7 +1060,7 @@ public void standardMoveFolder(IFolder source, IFolder destination, int flags, I
} catch (CoreException e) {
failed(e.getStatus());
// did the fail occur after copying to the destination?
failedDeletingSource = destStore != null && destStore.fetchInfo().exists();
failedDeletingSource = destStore != null && destStore.exists();
// if so, we should proceed
if (!failedDeletingSource) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2
Automatic-Module-Name: org.eclipse.ui.examples.filesystem
Bundle-Name: Efs Examples Plug-in
Bundle-SymbolicName: org.eclipse.ui.examples.filesystem;singleton:=true
Bundle-Version: 1.2.100.qualifier
Bundle-Version: 1.2.200.qualifier
Bundle-Vendor: Eclipse.org
Require-Bundle: org.eclipse.core.filesystem,
org.eclipse.core.resources,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,7 @@ private void searchInLink(IResource link) {
private void searchInStore(IFileStore store) {
try {
if (store.getName().equals(IProjectDescription.DESCRIPTION_FILE_NAME)) {
IFileInfo info = store.fetchInfo();
if (!info.isDirectory()) {
if (!store.isDirectory()) {
try (InputStream input = store.openInputStream(EFS.NONE, null)) {
IProjectDescription description = workspace.loadProjectDescription(input);
description.setLocationURI(store.getParent().toURI());
Expand Down
Loading
Loading