本文整理汇总了Java中org.eclipse.core.filesystem.IFileStore.delete方法的典型用法代码示例。如果您正苦于以下问题:Java IFileStore.delete方法的具体用法?Java IFileStore.delete怎么用?Java IFileStore.delete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.core.filesystem.IFileStore
的用法示例。
在下文中一共展示了IFileStore.delete方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deleteVirtualProjectAsync
import org.eclipse.core.filesystem.IFileStore; //导入方法依赖的package包/类
/**
* Removes virtual project which was created for debug session. Does its job
* asynchronously.
*/
public static void deleteVirtualProjectAsync(final IProject debugProject) {
Job job = new Job("Remove virtual project") {
@Override
protected IStatus run(IProgressMonitor monitor) {
URI projectUri = debugProject.getLocationURI();
try {
IFileStore projectStore = EFS.getStore(projectUri);
if (projectStore.fetchInfo().exists()) {
projectStore.delete(EFS.NONE, null);
}
debugProject.delete(true, null);
} catch (CoreException e) {
ChromiumDebugPlugin.log(e);
return new Status(IStatus.ERROR, ChromiumDebugPlugin.PLUGIN_ID,
"Failed to delete virtual project");
}
return Status.OK_STATUS;
}
};
job.schedule();
}
示例2: copyFile
import org.eclipse.core.filesystem.IFileStore; //导入方法依赖的package包/类
/**
* Copies a file as specified by {@link IFileStore#copy(IFileStore, int, IProgressMonitor)}.
*
* @param sourceInfo The current file information for the source of the move
* @param destination The destination of the copy.
* @param options bit-wise or of option flag constants ( {@link EFS#OVERWRITE} or {@link
* EFS#SHALLOW}).
* @param monitor a progress monitor, or <code>null</code> if progress reporting and cancellation
* are not desired
* @exception CoreException if this method fails. Reasons include:
* <ul>
* <li>This store does not exist.
* <li>The <code>OVERWRITE</code> flag is not specified and a file of the same name already
* exists at the copy destination.
* <li>A directory of the same name already exists at the copy destination.
* </ul>
*/
protected void copyFile(
IFileInfo sourceInfo, IFileStore destination, int options, IProgressMonitor monitor)
throws CoreException {
try {
if ((options & EFS.OVERWRITE) == 0 && destination.fetchInfo().exists())
Policy.error(EFS.ERROR_EXISTS, NLS.bind(Messages.fileExists, destination));
long length = sourceInfo.getLength();
int totalWork;
if (length == -1) totalWork = IProgressMonitor.UNKNOWN;
else totalWork = 1 + (int) (length / buffer.length);
String sourcePath = toString();
monitor.beginTask(NLS.bind(Messages.copying, sourcePath), totalWork);
InputStream in = null;
OutputStream out = null;
try {
in = openInputStream(EFS.NONE, Policy.subMonitorFor(monitor, 0));
out = destination.openOutputStream(EFS.NONE, Policy.subMonitorFor(monitor, 0));
transferStreams(in, out, sourcePath, monitor);
transferAttributes(sourceInfo, destination);
} catch (CoreException e) {
Policy.safeClose(in);
Policy.safeClose(out);
// if we failed to write, try to cleanup the half written file
if (!destination.fetchInfo(0, null).exists()) destination.delete(EFS.NONE, null);
throw e;
}
} finally {
monitor.done();
}
}
示例3: moveHistory
import org.eclipse.core.filesystem.IFileStore; //导入方法依赖的package包/类
/**
* Moves the project history from the old project to the new one.
*
* @param oldProject the old project, which does not exist anymore
* @param newProject the new project, which already exists
* @param monitor the progress monitor to use
*/
private void moveHistory(
final IProject oldProject, final IProject newProject, final IProgressMonitor monitor) {
try {
monitor.beginTask(RefactoringCoreMessages.RefactoringHistoryService_updating_history, 60);
final IFileStore historyStore =
EFS.getLocalFileSystem()
.getStore(RefactoringCorePlugin.getDefault().getStateLocation())
.getChild(NAME_HISTORY_FOLDER);
final String oldName = oldProject.getName();
final String newName = newProject.getName();
final IFileStore oldStore = historyStore.getChild(oldName);
if (oldStore
.fetchInfo(
EFS.NONE,
new SubProgressMonitor(monitor, 10, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL))
.exists()) {
final IFileStore newStore = historyStore.getChild(newName);
if (newStore
.fetchInfo(
EFS.NONE,
new SubProgressMonitor(monitor, 10, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL))
.exists())
newStore.delete(
EFS.NONE,
new SubProgressMonitor(monitor, 20, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
oldStore.move(
newStore,
EFS.OVERWRITE,
new SubProgressMonitor(monitor, 20, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
}
} catch (CoreException exception) {
RefactoringCorePlugin.log(exception);
} finally {
monitor.done();
}
}
示例4: removeIndexTree
import org.eclipse.core.filesystem.IFileStore; //导入方法依赖的package包/类
/**
* Removes the refactoring history index tree spanned by the specified file store.
*
* @param store the file store spanning the history index tree
* @param monitor the progress monitor to use
* @param task the task label to use
* @throws CoreException if an error occurs while removing the index tree
*/
private static void removeIndexTree(
final IFileStore store, final IProgressMonitor monitor, final String task)
throws CoreException {
try {
monitor.beginTask(task, 16);
final IFileInfo info =
store.fetchInfo(
EFS.NONE,
new SubProgressMonitor(monitor, 1, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
if (info.isDirectory()) {
if (info.getName().equalsIgnoreCase(RefactoringHistoryService.NAME_HISTORY_FOLDER)) return;
final IFileStore[] stores =
store.childStores(
EFS.NONE,
new SubProgressMonitor(monitor, 1, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
final IProgressMonitor subMonitor =
new SubProgressMonitor(monitor, 1, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL);
try {
subMonitor.beginTask(
RefactoringCoreMessages.RefactoringHistoryService_updating_history, stores.length);
for (int index = 0; index < stores.length; index++) {
final IFileInfo current =
stores[index].fetchInfo(
EFS.NONE,
new SubProgressMonitor(
subMonitor, 1, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
if (current.isDirectory()) {
final char[] characters = stores[index].getName().toCharArray();
for (int offset = 0; offset < characters.length; offset++) {
if (Character.isDigit(characters[offset])) return;
else continue;
}
}
}
} finally {
subMonitor.done();
}
}
final IFileStore parent = store.getParent();
store.delete(
0, new SubProgressMonitor(monitor, 1, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
removeIndexTree(
parent,
new SubProgressMonitor(monitor, 12, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL),
task);
} finally {
monitor.done();
}
}