Search in sources :

Example 21 with IFileStore

use of org.eclipse.core.filesystem.IFileStore in project eclipse.platform.text by eclipse.

the class TextFileDocumentProvider method isSystemFileReadOnly.

/**
 * Returns whether the system file denoted by
 * the given info is read-only.
 *
 * @param info the element's file info object
 * @return <code>true</code> iff read-only
 */
protected boolean isSystemFileReadOnly(FileInfo info) {
    IFileStore fileStore = getFileStore(info);
    if (fileStore == null)
        return false;
    IFileInfo fileInfo = fileStore.fetchInfo();
    return fileInfo.exists() && fileInfo.getAttribute(EFS.ATTRIBUTE_READ_ONLY);
}
Also used : IFileInfo(org.eclipse.core.filesystem.IFileInfo) IFileStore(org.eclipse.core.filesystem.IFileStore)

Example 22 with IFileStore

use of org.eclipse.core.filesystem.IFileStore in project eclipse.platform.text by eclipse.

the class UntitledTextFileWizard method performFinish.

@Override
public boolean performFinish() {
    IFileStore fileStore = queryFileStore();
    IEditorInput input = createEditorInput(fileStore);
    String editorId = getEditorId(fileStore);
    IWorkbenchPage page = fWindow.getActivePage();
    try {
        page.openEditor(input, editorId);
    } catch (PartInitException e) {
        EditorsPlugin.log(e);
        return false;
    }
    return true;
}
Also used : IFileStore(org.eclipse.core.filesystem.IFileStore) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) PartInitException(org.eclipse.ui.PartInitException) IEditorInput(org.eclipse.ui.IEditorInput)

Example 23 with IFileStore

use of org.eclipse.core.filesystem.IFileStore in project eclipse.platform.text by eclipse.

the class FileStoreFileBufferFunctions method test2.

/*
	 * Tests isSynchronized.
	 */
@Test
public void test2() throws Exception {
    fManager.connectFileStore(fFileStore, null);
    try {
        ITextFileBuffer fileBuffer = fManager.getFileStoreTextFileBuffer(fFileStore);
        assertTrue(fileBuffer.isSynchronized());
        IFileStore fileStore = fFileStore;
        IFileInfo fileInfo = fileStore.fetchInfo();
        fileInfo.setLastModified(1000);
        if (fileInfo.exists())
            fileStore.putInfo(fileInfo, EFS.SET_LAST_MODIFIED, null);
        long lastModified = fileStore.fetchInfo().getLastModified();
        assertTrue(lastModified == EFS.NONE || !fileBuffer.isSynchronized());
    } finally {
        fManager.disconnectFileStore(fFileStore, null);
    }
}
Also used : IFileInfo(org.eclipse.core.filesystem.IFileInfo) ITextFileBuffer(org.eclipse.core.filebuffers.ITextFileBuffer) IFileStore(org.eclipse.core.filesystem.IFileStore) Test(org.junit.Test)

Example 24 with IFileStore

use of org.eclipse.core.filesystem.IFileStore in project eclipse.platform.text by eclipse.

the class FileStoreFileBuffersForNonExistingWorkspaceFiles method setReadOnly.

/*
	 * @see org.eclipse.core.filebuffers.tests.FileBufferFunctions#markReadOnly()
	 */
@Override
protected void setReadOnly(boolean state) throws Exception {
    IFileStore fileStore = FileBuffers.getFileStoreAtLocation(getPath());
    assertNotNull(fileStore);
    fileStore.fetchInfo().setAttribute(EFS.ATTRIBUTE_READ_ONLY, state);
}
Also used : IFileStore(org.eclipse.core.filesystem.IFileStore)

Example 25 with IFileStore

use of org.eclipse.core.filesystem.IFileStore in project eclipse.platform.text by eclipse.

the class FileStoreFileBuffersForWorkspaceFiles method modifyUnderlyingFile.

@Override
protected boolean modifyUnderlyingFile() throws Exception {
    IFileStore fileStore = FileBuffers.getFileStoreAtLocation(getPath());
    assertTrue(fileStore.fetchInfo().exists());
    OutputStream out = fileStore.openOutputStream(EFS.NONE, null);
    try {
        out.write("Changed content of workspace file".getBytes());
        out.flush();
    } catch (IOException x) {
        fail();
    } finally {
        out.close();
    }
    IFileInfo fileInfo = fileStore.fetchInfo();
    fileInfo.setLastModified(1000);
    fileStore.putInfo(fileInfo, EFS.SET_LAST_MODIFIED, null);
    IFile iFile = FileBuffers.getWorkspaceFileAtLocation(getPath());
    assertTrue(iFile.exists() && iFile.getFullPath().equals(getPath()));
    iFile.refreshLocal(IResource.DEPTH_INFINITE, null);
    return true;
}
Also used : IFileInfo(org.eclipse.core.filesystem.IFileInfo) IFile(org.eclipse.core.resources.IFile) OutputStream(java.io.OutputStream) IFileStore(org.eclipse.core.filesystem.IFileStore) IOException(java.io.IOException)

Aggregations

IFileStore (org.eclipse.core.filesystem.IFileStore)178 CoreException (org.eclipse.core.runtime.CoreException)80 IOException (java.io.IOException)49 IPath (org.eclipse.core.runtime.IPath)42 IFileInfo (org.eclipse.core.filesystem.IFileInfo)33 URI (java.net.URI)30 Path (org.eclipse.core.runtime.Path)30 IFile (org.eclipse.core.resources.IFile)28 PartInitException (org.eclipse.ui.PartInitException)25 File (java.io.File)22 InputStream (java.io.InputStream)21 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)21 IRemoteFileProxy (org.eclipse.linuxtools.profiling.launch.IRemoteFileProxy)18 InputStreamReader (java.io.InputStreamReader)14 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)14 FileStoreEditorInput (org.eclipse.ui.ide.FileStoreEditorInput)14 BufferedInputStream (java.io.BufferedInputStream)13 BufferedReader (java.io.BufferedReader)13 ITextFileBuffer (org.eclipse.core.filebuffers.ITextFileBuffer)11 IStatus (org.eclipse.core.runtime.IStatus)11