org.eclipse.core.filesystem.EFS类的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(9.7k)|赞(0)|评价(0)|浏览(139)

本文整理了Java中org.eclipse.core.filesystem.EFS类的一些代码示例,展示了EFS类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。EFS类的具体详情如下:
包路径:org.eclipse.core.filesystem.EFS
类名称:EFS

EFS介绍

[英]This class is the main entry point for clients of the Eclipse file system API. This class has factory methods for obtaining instances of file systems and file stores, and provides constants for option values and error codes.
[中]此类是Eclipse文件系统API客户端的主要入口点。此类具有用于获取文件系统和文件存储实例的工厂方法,并为选项值和错误代码提供常量。

代码示例

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.core.resources

/**
 * Returns a string representation of a URI suitable for displaying to an end user.
 */
private String toString(URI uri) {
  try {
    return EFS.getStore(uri).toString();
  } catch (CoreException e) {
    //there is no store defined, so the best we can do is the URI toString.
    return uri.toString();
  }
}

代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.core

/**
 * Returns whether the local file system supports accessing and modifying
 * the given attribute.
 */
protected static boolean isAttributeSupported(int attribute) {
  return (EFS.getLocalFileSystem().attributes() & attribute) != 0;
}

代码示例来源:origin: org.eclipse.emf.cdo.workspace/efs

private static CDOWorkspaceFileSystem getFileSystem() throws CoreException
{
 return (CDOWorkspaceFileSystem)EFS.getFileSystem(CDOWorkspaceFileSystem.SCHEME);
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.ui.ide

@Override
public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) {
  if (IPathEditorInput.class.equals(adapterType)) {
    if (adaptableObject instanceof IURIEditorInput) {
      IFileStore fileStore;
      try {
        fileStore= EFS.getStore(((IURIEditorInput) adaptableObject).getURI());
        if (fileStore.getFileSystem() == EFS.getLocalFileSystem()) {
          return adapterType.cast(new PathEditorInputAdapter(fileStore));
        }
      } catch (CoreException e) {
        return null;
      }
    }
  }
  return null;
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.core.resources

/**
 * Creates an IFileStore for a given workspace path. The prefix of the path of
 * the returned IFileStore corresponding to this root is canonicalized.
 * @exception CoreException If the file system for that resource is undefined
 */
IFileStore createStore(IPath workspacePath, IResource resource) throws CoreException {
  IPath childPath = workspacePath.removeFirstSegments(chop);
  IFileStore rootStore;
  final URI uri = resource.getPathVariableManager().resolveURI(getCanonicalRoot());
  if (!uri.isAbsolute()) {
    //handles case where resource location cannot be resolved
    //such as unresolved path variable or invalid file system scheme
    return EFS.getNullFileSystem().getStore(workspacePath);
  }
  rootStore = EFS.getStore(uri);
  if (childPath.segmentCount() == 0)
    return rootStore;
  return rootStore.getFileStore(childPath);
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.core.resources

@Override
public IFileStore getChild(String name) {
  return EFS.getNullFileSystem().getStore(new Path(name).makeAbsolute());
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.core.filebuffers

/**
 * Returns the file in the local file system for the given location.
 * <p>
 * The location is either a full path of a workspace resource or an
 * absolute path in the local file system.
 * </p>
 *
 * @param location the location
 * @return the {@link IFileStore} in the local file system for the given location
 * @since 3.2
 */
public static IFileStore getFileStoreAtLocation(IPath location) {
  if (location == null)
    return null;
  IFile file= getWorkspaceFileAtLocation(location);
  try {
    if (file != null) {
      URI uri= file.getLocationURI();
      if (uri == null)
        return null;
      return EFS.getStore(uri);
    }
  } catch (CoreException e) {
    //fall through and assume it is a local file
  }
  return EFS.getLocalFileSystem().getStore(location);
}

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.eclipse.core.resources

/**
 * Creates an IFileStore for a given workspace path. The prefix of the path of
 * the returned IFileStore corresponding to this root is canonicalized.
 * @exception CoreException If the file system for that resource is undefined
 */
IFileStore createStore(IPath workspacePath, IResource resource) throws CoreException {
  IPath childPath = workspacePath.removeFirstSegments(chop);
  IFileStore rootStore;
  final URI uri = resource.getPathVariableManager().resolveURI(getCanonicalRoot());
  if (!uri.isAbsolute()) {
    //handles case where resource location cannot be resolved
    //such as unresolved path variable or invalid file system scheme
    return EFS.getNullFileSystem().getStore(workspacePath);
  }
  rootStore = EFS.getStore(uri);
  if (childPath.segmentCount() == 0)
    return rootStore;
  return rootStore.getFileStore(childPath);
}

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.eclipse.core.resources

@Override
public IFileStore getChild(String name) {
  return EFS.getNullFileSystem().getStore(new Path(name).makeAbsolute());
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.ui.ide

@Override
public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) {
  if (adaptableObject instanceof FileStoreEditorInput && adapterType.isAssignableFrom(IFileStore.class)) {
    FileStoreEditorInput editorInput = (FileStoreEditorInput) adaptableObject;
    try {
      return adapterType.cast(EFS.getStore(editorInput.getURI()));
    } catch (CoreException e) {
      // Ignore to return null.
    }
  }
  return null;
}

代码示例来源:origin: trylimits/Eclipse-Postfix-Code-Completion

/**
 * Returns whether the local file system supports accessing and modifying
 * the given attribute.
 */
protected static boolean isAttributeSupported(int attribute) {
  return (EFS.getLocalFileSystem().attributes() & attribute) != 0;
}

代码示例来源:origin: org.eclipse/org.eclipse.core.filebuffers

/**
 * Returns the file in the local file system for the given location.
 * <p>
 * The location is either a full path of a workspace resource or an
 * absolute path in the local file system.
 * </p>
 *
 * @param location the location
 * @return the {@link IFileStore} in the local file system for the given location
 * @since 3.2
 */
public static IFileStore getFileStoreAtLocation(IPath location) {
  if (location == null)
    return null;
  IFile file= getWorkspaceFileAtLocation(location);
  try {
    if (file != null) {
      URI uri= file.getLocationURI();
      if (uri == null)
        return null;
      return EFS.getStore(uri);
    }
  } catch (CoreException e) {
    //fall through and assume it is a local file
  }
  return EFS.getLocalFileSystem().getStore(location);
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.core.resources

/**
 * Creates an IFileStore for a given workspace path. The prefix of the path of
 * the returned IFileStore corresponding to this root is canonicalized.
 * @exception CoreException If the file system for that resource is undefined
 */
IFileStore createStore(IPath workspacePath, IResource resource) throws CoreException {
  IPath childPath = workspacePath.removeFirstSegments(chop);
  // For a linked resource itself we have to use its root, but for its children we prefer
  // to use the canonical root since it provides for faster file system access.
  // See http://bugs.eclipse.org/507084
  final URI uri = resource.getPathVariableManager().resolveURI(resource.isLinked() ? root : getCanonicalRoot());
  if (!uri.isAbsolute()) {
    // Handles case where resource location cannot be resolved such as
    // unresolved path variable or invalid file system scheme.
    return EFS.getNullFileSystem().getStore(workspacePath);
  }
  IFileStore rootStore = EFS.getStore(uri);
  if (childPath.segmentCount() == 0)
    return rootStore;
  return rootStore.getFileStore(childPath);
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.core.filesystem

/**
 * The default implementation of {@link IFileStore#getFileSystem()}.
 * Subclasses may override.
 */
@Override
public IFileSystem getFileSystem() {
  try {
    return EFS.getFileSystem(toURI().getScheme());
  } catch (CoreException e) {
    //this will only happen if toURI() has been incorrectly implemented
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.core.resources

@Override
public IFileStore getChild(String name) {
  return EFS.getNullFileSystem().getStore(new Path(name).makeAbsolute());
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.core.resources

/**
 * Returns a string representation of a URI suitable for displaying to an end user.
 */
private String toString(URI uri) {
  try {
    return EFS.getStore(uri).toString();
  } catch (CoreException e) {
    //there is no store defined, so the best we can do is the URI toString.
    return uri.toString();
  }
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.core

/**
 * Returns whether the local file system supports accessing and modifying
 * the given attribute.
 */
protected static boolean isAttributeSupported(int attribute) {
  return (EFS.getLocalFileSystem().attributes() & attribute) != 0;
}

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.eclipse.debug.core

/**
 * Returns the file store this configuration is persisted in or <code>null</code> if
 * a file store cannot be derived. The file may or may not exist. If this configuration
 * is in a project that is closed or does not exist, <code>null</code> is returned.
 *
 * @return file store this configuration is persisted in or <code>null</code>
 * @throws CoreException if a problem is encountered
 * @since 3.5
 */
public IFileStore getFileStore() throws CoreException {
  if (isLocal()) {
    return EFS.getLocalFileSystem().fromLocalFile(
      LaunchManager.LOCAL_LAUNCH_CONFIGURATION_CONTAINER_PATH.append(getFileName()).toFile());
  }
  URI uri = getFile().getLocationURI();
  if (uri != null) {
    return EFS.getStore(uri);
  }
  return null;
}

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.eclipse.core.filesystem

/**
 * The default implementation of {@link IFileStore#getFileSystem()}.
 * Subclasses may override.
 */
@Override
public IFileSystem getFileSystem() {
  try {
    return EFS.getFileSystem(toURI().getScheme());
  } catch (CoreException e) {
    //this will only happen if toURI() has been incorrectly implemented
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.eclipse.core.filesystem

/**
 * This is the default implementation of {@link IFileSystem#getStore(IPath)}.  
 * This implementation forwards to {@link IFileSystem#getStore(URI)}, 
 * assuming that the provided path corresponds to the path component of the 
 * URI for the file store.
 * <p>
 * Subclasses may override this method.  If it is not possible to create a file
 * store corresponding to the provided path for this file system, a file store
 * belonging to the null file system should be returned
 * </p>
 * 
 * @param path A path to a file store within the scheme of this file system.
 * @return A handle to a file store in this file system
 * @see IFileSystem#getStore(IPath)
 * @see EFS#getNullFileSystem()
 */
@Override
public IFileStore getStore(IPath path) {
  try {
    return getStore(new URI(scheme, path.toString(), null));
  } catch (URISyntaxException e) {
    return EFS.getNullFileSystem().getStore(path);
  }
}

相关文章