Java Code Examples for org.eclipse.core.filesystem.IFileStore#getParent()
The following examples show how to use
org.eclipse.core.filesystem.IFileStore#getParent() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LeakTest.java From textuml with Eclipse Public License 1.0 | 6 votes |
public void testLeak2() throws Exception { ICompilationDirector director = CompilationDirector.getInstance(); IFileStore sourceRoot = EFS.getStore(java.net.URI .create("file:///C:/Users/rafael/AppData/Local/Temp/kirra/perf2/src")); IFileStore output = sourceRoot.getParent(); LocationContext context = new LocationContext(output); context.addSourcePath(sourceRoot, output); IFileStore[] allChildren = sourceRoot.childStores(EFS.NONE, null); List<IFileStore> source = new ArrayList<IFileStore>(); for (IFileStore iFileStore : allChildren) if (iFileStore.getName().endsWith("tuml")) source.add(iFileStore); IProblem[] problems = director.compile(source.toArray(new IFileStore[0]), null, context, ICompilationDirector.FULL_BUILD | ICompilationDirector.CLEAN, null); FixtureHelper.assertCompilationSuccessful(problems); showMemory("after test"); }
Example 2
Source File: GoNavigatorContentProvider.java From goclipse with Eclipse Public License 1.0 | 6 votes |
@Override protected LangNavigatorSwitcher_GetParent getParent_switcher() { return new LangNavigatorSwitcher_GetParent() { @Override public Object visitGoPathElement(GoPathElement goPathElement) { return null; // TODO: project parent } @Override public Object visitFileStoreElement(IFileStore fileStore) { // TODO: trim this at the GOROOT directory return fileStore.getParent(); } }; }
Example 3
Source File: NewFileServlet.java From orion.server with Eclipse Public License 1.0 | 5 votes |
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { traceRequest(req); String pathInfo = req.getPathInfo(); IPath path = pathInfo == null ? Path.ROOT : new Path(pathInfo); // prevent path canonicalization hacks if (pathInfo != null && !pathInfo.equals(path.toString())) { handleException(resp, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_FORBIDDEN, NLS.bind("Forbidden: {0}", pathInfo), null)); return; } //don't allow anyone to mess with metadata if (path.segmentCount() > 0 && ".metadata".equals(path.segment(0))) { //$NON-NLS-1$ handleException(resp, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_FORBIDDEN, NLS.bind("Forbidden: {0}", pathInfo), null)); return; } IFileStore file = getFileStore(req, path); IFileStore testLink = file; while (testLink != null) { IFileInfo info = testLink.fetchInfo(); if (info.getAttribute(EFS.ATTRIBUTE_SYMLINK)) { if (file == testLink) { handleException(resp, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_FORBIDDEN, NLS.bind("Forbidden: {0}", EncodingUtils.encodeForHTML(pathInfo.toString())), null)); } else { handleException(resp, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_NOT_FOUND, NLS.bind("File not found: {0}", EncodingUtils.encodeForHTML(pathInfo.toString())), null)); } return; } testLink = testLink.getParent(); } if (file == null) { handleException(resp, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_NOT_FOUND, NLS.bind("File not found: {0}", EncodingUtils.encodeForHTML(pathInfo.toString())), null)); return; } if (fileSerializer.handleRequest(req, resp, file)) return; // finally invoke super to return an error for requests we don't know how to handle super.doGet(req, resp); }
Example 4
Source File: ResourceUtils.java From xds-ide with Eclipse Public License 1.0 | 5 votes |
public static IFileStore getSibling(IFileStore file, String name) { IFileStore parent = file.getParent(); if (parent == null) { return null; } return parent.getChild(name); }
Example 5
Source File: RemoteGenerateManifestOperation.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
private void filterElements(TracePackageElement parentElement) { for (TracePackageElement childElement : parentElement.getChildren()) { filterElements(childElement); if (childElement instanceof TracePackageTraceElement) { // no need to do length check here RemoteImportTraceFilesElement filesElement = (RemoteImportTraceFilesElement) childElement.getChildren()[0]; IFileStore parentFile = filesElement.getRemoteFile().getParent(); if (fDirectoryTraces.contains(TmfTraceCoreUtils.newSafePath(parentFile.toURI().getPath()))) { removeChild(childElement, parentElement); continue; } IFileStore grandParentFile = parentFile.getParent(); if (grandParentFile != null && fDirectoryTraces.contains(TmfTraceCoreUtils.newSafePath(grandParentFile.toURI().getPath()))) { // ignore file if grandparent is a directory trace // for example: file is a index file of a LTTng kernel trace parentElement.removeChild(childElement); if (parentElement.getChildren().length == 0) { TracePackageElement grandParentElement = parentElement.getParent(); removeChild(parentElement, grandParentElement); } continue; } } else if (childElement instanceof RemoteImportFolderElement) { if (childElement.getChildren().length == 0) { parentElement.removeChild(childElement); } } } }
Example 6
Source File: CopyFilesAndFoldersOperation.java From Pydev with Eclipse Public License 1.0 | 5 votes |
/** * Checks whether the destination is valid for copying the source file * stores. * <p> * Note this method is for internal use only. It is not API. * </p> * <p> * TODO Bug 117804. This method has been renamed to avoid a bug in the * Eclipse compiler with regards to visibility and type resolution when * linking. * </p> * * @param destination * the destination container * @param sourceStores * the source IFileStore * @return an error message, or <code>null</code> if the path is valid */ private String validateImportDestinationInternal(IContainer destination, IFileStore[] sourceStores) { if (!isAccessible(destination)) { return IDEWorkbenchMessages.CopyFilesAndFoldersOperation_destinationAccessError; } IFileStore destinationStore; try { destinationStore = EFS.getStore(destination.getLocationURI()); } catch (CoreException exception) { IDEWorkbenchPlugin.log(exception.getLocalizedMessage(), exception); return NLS.bind(IDEWorkbenchMessages.CopyFilesAndFoldersOperation_internalError, exception.getLocalizedMessage()); } for (int i = 0; i < sourceStores.length; i++) { IFileStore sourceStore = sourceStores[i]; IFileStore sourceParentStore = sourceStore.getParent(); if (sourceStore != null) { if (destinationStore.equals(sourceStore) || (sourceParentStore != null && destinationStore.equals(sourceParentStore))) { return NLS.bind(IDEWorkbenchMessages.CopyFilesAndFoldersOperation_importSameSourceAndDest, sourceStore.getName()); } // work around bug 16202. replacement for // sourcePath.isPrefixOf(destinationPath) IFileStore destinationParent = destinationStore.getParent(); if (sourceStore.isParentOf(destinationParent)) { return IDEWorkbenchMessages.CopyFilesAndFoldersOperation_destinationDescendentError; } } } return null; }
Example 7
Source File: RemoteGenerateManifestOperation.java From tracecompass with Eclipse Public License 2.0 | 4 votes |
/** * Scan traceFolder for files that match the patterns specified in the * template file. When there is a match, the trace package element is used * to determine the trace name and trace type. * * @param traceGroup * The parent trace group element * @param parentElement * The immediate parent trace group or folder element * @param traceFolder * The folder to scan * @param recursionLevel * The recursion level (needed to find directory traces under the traceFolder * @param monitor * The progress monitor * @throws CoreException * Thrown by the file system implementation * @throws InterruptedException * Thrown if operation was cancelled */ private void generateElementsFromArchive( final RemoteImportTraceGroupElement traceGroup, final TracePackageElement parentElement, final IFileStore traceFolder, final int recursionLevel, IProgressMonitor monitor) throws CoreException, InterruptedException { int localRecursionLevel = recursionLevel + 1; IFileStore[] sources = traceFolder.childStores(EFS.NONE, monitor); for (int i = 0; i < sources.length; i++) { ModalContext.checkCanceled(monitor); SubMonitor subMonitor = SubMonitor.convert(monitor, sources.length); IFileStore fileStore = sources[i]; IPath fullArchivePath = TmfTraceCoreUtils.newSafePath(fileStore.toURI().getPath()); IFileInfo sourceInfo = fileStore.fetchInfo(); if (!sourceInfo.isDirectory()) { String rootPathString = traceGroup.getRootImportPath(); IPath rootPath = TmfTraceCoreUtils.newSafePath(rootPathString); IPath relativeTracePath = Path.EMPTY; if (rootPath.isPrefixOf(fullArchivePath)) { relativeTracePath = fullArchivePath.makeRelativeTo(rootPath); } Entry<Pattern, TracePackageTraceElement> matchingTemplateEntry = getMatchingTemplateElement(relativeTracePath); if (matchingTemplateEntry != null) { TracePackageTraceElement matchingTemplateElement = matchingTemplateEntry.getValue(); String traceType = matchingTemplateElement.getTraceType(); // If a single file is part of a directory trace, use the parent directory instead TracePackageElement parent = parentElement; if (matchesDirectoryTrace(relativeTracePath, matchingTemplateEntry)) { fullArchivePath = fullArchivePath.removeLastSegments(1); fDirectoryTraces.add(fullArchivePath); fileStore = fileStore.getParent(); sourceInfo = fileStore.fetchInfo(); parent = parentElement.getParent(); // Let the auto-detection choose the best trace type traceType = null; } else if ((localRecursionLevel > 1) && (!traceGroup.isRecursive())) { // Don't consider file traces on level 2 if it's not recursive continue; } if (sourceInfo.getLength() > 0 || sourceInfo.isDirectory()) { // Only add non-empty files String traceName = fullArchivePath.lastSegment(); String fileName = fileStore.getName(); // create new elements to decouple from input elements TracePackageTraceElement traceElement = new TracePackageTraceElement(parent, traceName, traceType); RemoteImportTraceFilesElement tracePackageFilesElement = new RemoteImportTraceFilesElement(traceElement, fileName, fileStore); tracePackageFilesElement.setVisible(false); } } } else { if (traceGroup.isRecursive() || localRecursionLevel < 2) { RemoteImportFolderElement folder = new RemoteImportFolderElement(parentElement, fileStore.getName()); generateElementsFromArchive(traceGroup, folder, fileStore, localRecursionLevel, subMonitor); } } } }