use of org.eclipse.core.filesystem.IFileInfo in project che by eclipse.
the class RefactoringHistoryManager method readRefactoringDescriptorProxies.
/**
* Reads refactoring descriptor proxies.
*
* @param store
* the file store to read
* @param project
* the name of the project, or <code>null</code> for the
* workspace
* @param collection
* the collection of proxies to fill in
* @param start
* the start time stamp, inclusive
* @param end
* the end time stamp, inclusive
* @param monitor
* the progress monitor to use
* @param task
* the task label to use
* @throws CoreException
* if an error occurs
*/
private static void readRefactoringDescriptorProxies(final IFileStore store, final String project, final Collection collection, final long start, final long end, final IProgressMonitor monitor, final String task) throws CoreException {
try {
monitor.beginTask(RefactoringCoreMessages.RefactoringHistoryService_retrieving_history, 22);
final IFileInfo info = store.fetchInfo(EFS.NONE, new SubProgressMonitor(monitor, 2, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
if (!info.isDirectory() && info.exists() && store.getName().equalsIgnoreCase(RefactoringHistoryService.NAME_INDEX_FILE)) {
InputStream stream = null;
try {
stream = store.openInputStream(EFS.NONE, new SubProgressMonitor(monitor, 1, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
final RefactoringDescriptorProxy[] proxies = readRefactoringDescriptorProxies(stream, project, start, end);
for (int index = 0; index < proxies.length; index++) collection.add(proxies[index]);
monitor.worked(1);
} catch (IOException exception) {
throw createCoreException(exception);
} finally {
monitor.worked(1);
if (stream != null) {
try {
stream.close();
} catch (IOException exception) {
// Do nothing
}
}
monitor.worked(1);
}
} else
monitor.worked(4);
if (monitor.isCanceled())
throw new OperationCanceledException();
final IFileStore[] stores = store.childStores(EFS.NONE, new SubProgressMonitor(monitor, 2, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
final IProgressMonitor subMonitor = new SubProgressMonitor(monitor, 12);
try {
subMonitor.beginTask(task, stores.length);
for (int index = 0; index < stores.length; index++) readRefactoringDescriptorProxies(stores[index], project, collection, start, end, new SubProgressMonitor(subMonitor, 1), task);
} finally {
subMonitor.done();
}
} finally {
monitor.done();
}
}
use of org.eclipse.core.filesystem.IFileInfo in project che by eclipse.
the class FileStoreFileBuffer method create.
public void create(IFileStore fileStore, IProgressMonitor monitor) throws CoreException {
IFileInfo info = fileStore.fetchInfo();
fFileStore = fileStore;
if (fLocation == null)
fLocation = URIUtil.toPath(fileStore.toURI());
initializeFileBufferContent(monitor);
if (info.exists())
fSynchronizationStamp = info.getLastModified();
addFileBufferContentListeners();
}
use of org.eclipse.core.filesystem.IFileInfo in project che by eclipse.
the class FileStore method copy.
/**
* The default implementation of {@link IFileStore#copy(IFileStore, int, IProgressMonitor)}.
* This implementation performs a copy by using other primitive methods.
* Subclasses may override this method.
*/
public void copy(IFileStore destination, int options, IProgressMonitor monitor) throws CoreException {
monitor = Policy.monitorFor(monitor);
Policy.checkCanceled(monitor);
final IFileInfo sourceInfo = fetchInfo(EFS.NONE, null);
if (sourceInfo.isDirectory())
copyDirectory(sourceInfo, destination, options, monitor);
else
copyFile(sourceInfo, destination, options, monitor);
}
use of org.eclipse.core.filesystem.IFileInfo in project che by eclipse.
the class LocalFile method fetchInfo.
public IFileInfo fetchInfo(int options, IProgressMonitor monitor) {
// if (LocalFileNativesManager.isUsingNatives()) {
// FileInfo info = LocalFileNativesManager.fetchFileInfo(filePath);
// //natives don't set the file name on all platforms
// if (info.getName().length() == 0) {
// String name = file.getName();
// //Bug 294429: make sure that substring baggage is removed
// info.setName(new String(name.toCharArray()));
// }
// return info;
// }
//in-lined non-native implementation
FileInfo info = new FileInfo(file.getName());
final long lastModified = file.lastModified();
if (lastModified <= 0) {
//if the file doesn't exist, all other attributes should be default values
info.setExists(false);
return info;
}
info.setLastModified(lastModified);
info.setExists(true);
info.setLength(file.length());
info.setDirectory(file.isDirectory());
info.setAttribute(EFS.ATTRIBUTE_READ_ONLY, file.exists() && !file.canWrite());
info.setAttribute(EFS.ATTRIBUTE_HIDDEN, file.isHidden());
return info;
}
use of org.eclipse.core.filesystem.IFileInfo in project eclipse.platform.text by eclipse.
the class FileBuffersForFilesInLinkedFolders 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 file in linked folder".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());
iFile.refreshLocal(IResource.DEPTH_INFINITE, null);
return true;
}
Aggregations