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);
}
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;
}
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);
}
}
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);
}
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;
}
Aggregations