use of org.eclipse.core.filesystem.IFileStore in project eclipse.platform.text by eclipse.
the class FileBuffersForNonAccessibleWorkspaceFiles 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 FileBuffersForNonExistingWorkspaceFiles 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 FileBufferCreation method test7_IFileStore.
/*
* Tests the creation of a file buffer for a non-existing file.
*/
@Test
public void test7_IFileStore() throws Exception {
IPath path = FileBuffersTestPlugin.getDefault().getStateLocation();
path = path.append("NonExistingFile");
IFileStore fileStore = EFS.getLocalFileSystem().getStore(path);
ITextFileBufferManager manager = FileBuffers.getTextFileBufferManager();
manager.connectFileStore(fileStore, null);
ITextFileBuffer buffer = manager.getFileStoreTextFileBuffer(fileStore);
Assert.assertNotNull(buffer);
IDocument document = buffer.getDocument();
Assert.assertNotNull(document);
Assert.assertTrue("".equals(document.get()));
assertSame(buffer, manager.getTextFileBuffer(document));
manager.disconnectFileStore(fileStore, null);
assertNull(manager.getFileStoreTextFileBuffer(fileStore));
}
use of org.eclipse.core.filesystem.IFileStore in project eclipse.platform.text by eclipse.
the class FileBufferFunctions method test2.
/*
* Tests isSynchronized.
*/
@Test
public void test2() throws Exception {
fManager.connect(fPath, LocationKind.NORMALIZE, null);
try {
ITextFileBuffer fileBuffer = fManager.getTextFileBuffer(fPath, LocationKind.NORMALIZE);
assertTrue(fileBuffer.isSynchronized());
IFileStore fileStore = FileBuffers.getFileStoreAtLocation(fPath);
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.disconnect(fPath, LocationKind.NORMALIZE, null);
}
}
use of org.eclipse.core.filesystem.IFileStore in project eclipse.platform.text by eclipse.
the class FileBufferFunctions method test6.
/*
* Test revert.
*/
@Test
public void test6() throws Exception {
fManager.connect(fPath, LocationKind.NORMALIZE, null);
try {
ITextFileBuffer fileBuffer = fManager.getTextFileBuffer(fPath, LocationKind.NORMALIZE);
// set dirty bit
IDocument document = fileBuffer.getDocument();
String originalContent = document.get();
document.replace(document.getLength(), 0, "appendix");
// invalidate synchronization state
IFileStore fileStore = FileBuffers.getFileStoreAtLocation(fPath);
IFileInfo fileInfo = fileStore.fetchInfo();
fileInfo.setLastModified(1000);
if (fileInfo.exists())
fileStore.putInfo(fileInfo, EFS.SET_LAST_MODIFIED, null);
// revert
fileBuffer.revert(null);
// check assertions
assertEquals(originalContent, document.get());
assertFalse(fileBuffer.isDirty());
assertTrue(fileBuffer.isSynchronized());
} finally {
fManager.disconnect(fPath, LocationKind.NORMALIZE, null);
}
}
Aggregations