本文整理汇总了Java中org.eclipse.core.filesystem.IFileInfo类的典型用法代码示例。如果您正苦于以下问题:Java IFileInfo类的具体用法?Java IFileInfo怎么用?Java IFileInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IFileInfo类属于org.eclipse.core.filesystem包,在下文中一共展示了IFileInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkLocationDeleted
import org.eclipse.core.filesystem.IFileInfo; //导入依赖的package包/类
void checkLocationDeleted(final IProject project) throws CoreException {
if (!project.exists()) { return; }
final IFileInfo location = IDEResourceInfoUtils.getFileInfo(project.getLocationURI());
if (!location.exists()) {
final String message = NLS.bind(IDEWorkbenchMessages.RefreshAction_locationDeletedMessage,
project.getName(), location.toString());
final MessageDialog dialog = new MessageDialog(WorkbenchHelper.getShell(),
IDEWorkbenchMessages.RefreshAction_dialogTitle, null, message, MessageDialog.QUESTION,
new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0) {
@Override
protected int getShellStyle() {
return super.getShellStyle() | SWT.SHEET;
}
};
WorkbenchHelper.run(() -> dialog.open());
// Do the deletion back in the operation thread
if (dialog.getReturnCode() == 0) { // yes was chosen
project.delete(true, true, null);
}
}
}
示例2: checkLocationDeleted
import org.eclipse.core.filesystem.IFileInfo; //导入依赖的package包/类
/**
* Checks whether the given project's location has been deleted. If so, prompts the user with whether to delete the
* project or not.
*/
void checkLocationDeleted(final IProject project) throws CoreException {
if (!project.exists()) { return; }
final IFileInfo location = IDEResourceInfoUtils.getFileInfo(project.getLocationURI());
if (!location.exists()) {
final String message = NLS.bind(IDEWorkbenchMessages.RefreshAction_locationDeletedMessage,
project.getName(), location.toString());
final MessageDialog dialog = new MessageDialog(WorkbenchHelper.getShell(),
IDEWorkbenchMessages.RefreshAction_dialogTitle, null, message, MessageDialog.QUESTION,
new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0) {
@Override
protected int getShellStyle() {
return super.getShellStyle() | SWT.SHEET;
}
};
WorkbenchHelper.run(() -> dialog.open());
// Do the deletion back in the operation thread
if (dialog.getReturnCode() == 0) { // yes was chosen
project.delete(true, true, null);
}
}
}
示例3: putInfo
import org.eclipse.core.filesystem.IFileInfo; //导入依赖的package包/类
void putInfo(IPath path, IFileInfo info, int options) throws CoreException {
CommonNode node = find(path);
if (node == null) {
throw newCoreException("The store does not exist: " + path, null); //$NON-NLS-1$
} else {
if ((options & EFS.SET_ATTRIBUTES) != 0) {
copyAttribute(info, node.info, EFS.ATTRIBUTE_ARCHIVE);
copyAttribute(info, node.info, EFS.ATTRIBUTE_EXECUTABLE);
copyAttribute(info, node.info, EFS.ATTRIBUTE_HIDDEN);
copyAttribute(info, node.info, EFS.ATTRIBUTE_LINK_TARGET);
copyAttribute(info, node.info, EFS.ATTRIBUTE_READ_ONLY);
}
if ((options & EFS.SET_LAST_MODIFIED) != 0) {
node.info.setLastModified(info.getLastModified());
}
}
}
示例4: fetchInfo
import org.eclipse.core.filesystem.IFileInfo; //导入依赖的package包/类
/**
* Get file info for this directory.
*/
/* Override */
public IFileInfo fetchInfo( int options, IProgressMonitor monitor )
throws CoreException
{
updateZXTM();
FileInfo info = new FileInfo( name );
if( zxtm == null ) {
info.setExists( false );
info.setDirectory( true );
info.setLength( EFS.NONE );
info.setLastModified( EFS.NONE );
} else {
info.setExists( true );
info.setDirectory( true );
info.setLength( EFS.NONE );
info.setLastModified( EFS.NONE );
info.setAttribute( EFS.ATTRIBUTE_READ_ONLY, false );
}
return info;
}
示例5: isValid
import org.eclipse.core.filesystem.IFileInfo; //导入依赖的package包/类
@Override
public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException {
RefactoringStatus result= new RefactoringStatus();
IFile file= ResourcesPlugin.getWorkspace().getRoot().getFile(fPath);
URI location= file.getLocationURI();
if (location == null) {
result.addFatalError(Messages.format(
NLSChangesMessages.CreateFileChange_error_unknownLocation,
BasicElementLabels.getPathLabel(file.getFullPath(), false)));
return result;
}
IFileInfo jFile= EFS.getStore(location).fetchInfo();
if (jFile.exists()) {
result.addFatalError(Messages.format(
NLSChangesMessages.CreateFileChange_error_exists,
BasicElementLabels.getPathLabel(file.getFullPath(), false)));
return result;
}
return result;
}
示例6: rememberExisitingFolders
import org.eclipse.core.filesystem.IFileInfo; //导入依赖的package包/类
private void rememberExisitingFolders(URI projectLocation) {
fOrginalFolders= new HashSet<IFileStore>();
try {
IFileStore[] children= EFS.getStore(projectLocation).childStores(EFS.NONE, null);
for (int i= 0; i < children.length; i++) {
IFileStore child= children[i];
IFileInfo info= child.fetchInfo();
if (info.isDirectory() && info.exists() && !fOrginalFolders.contains(child.getName())) {
fOrginalFolders.add(child);
}
}
} catch (CoreException e) {
JavaPlugin.log(e);
}
}
示例7: getEditorInput
import org.eclipse.core.filesystem.IFileInfo; //导入依赖的package包/类
private static IEditorInput getEditorInput(final String path) {
final IFile file = Resources.getFileForLocation(path);
if (file != null) {
return new FileEditorInput(file);
} else {
// file is outside of workbench
final IFileStore fileStore = EFS.getLocalFileSystem().getStore(new Path(path));
final IFileInfo fetchInfo = fileStore.fetchInfo();
if (fetchInfo.isDirectory() || !fetchInfo.exists()) {
return null; // ensure the file exists
}
return new FileStoreEditorInput(fileStore);
}
}
示例8: openEditor
import org.eclipse.core.filesystem.IFileInfo; //导入依赖的package包/类
private IEditorPart openEditor(IWorkbenchWindow window, IPath filePath) {
IFileStore fileStore = EFS.getLocalFileSystem().getStore(filePath);
IFileInfo fetchInfo = fileStore.fetchInfo();
if (fetchInfo.isDirectory() || !fetchInfo.exists()) {
return null;
}
IWorkbenchPage page = window.getActivePage();
try {
IEditorPart editorPart = IDE.openEditorOnFileStore(page, fileStore);
return editorPart;
} catch (PartInitException e) {
return null;
}
}
示例9: fetchInfo
import org.eclipse.core.filesystem.IFileInfo; //导入依赖的package包/类
@Override
public IFileInfo fetchInfo(int options, IProgressMonitor monitor) throws CoreException {
FileInfo fileInfo = new FileInfo(getName());
fileInfo.setExists(true);
fileInfo.setAttribute(EFS.ATTRIBUTE_OWNER_WRITE, true);
return fileInfo;
}
示例10: create
import org.eclipse.core.filesystem.IFileInfo; //导入依赖的package包/类
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();
}
示例11: copy
import org.eclipse.core.filesystem.IFileInfo; //导入依赖的package包/类
/**
* 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);
}
示例12: copyDirectory
import org.eclipse.core.filesystem.IFileInfo; //导入依赖的package包/类
/**
* Recursively copies a directory 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>A file of the same name already exists at the copy destination.
* </ul>
*/
protected void copyDirectory(
IFileInfo sourceInfo, IFileStore destination, int options, IProgressMonitor monitor)
throws CoreException {
try {
IFileStore[] children = null;
int opWork = 1;
if ((options & EFS.SHALLOW) == 0) {
children = childStores(EFS.NONE, null);
opWork += children.length;
}
monitor.beginTask("", opWork); // $NON-NLS-1$
monitor.subTask(NLS.bind(Messages.copying, toString()));
// create directory
destination.mkdir(EFS.NONE, Policy.subMonitorFor(monitor, 1));
// copy attributes
transferAttributes(sourceInfo, destination);
if (children == null) return;
// copy children
for (int i = 0; i < children.length; i++)
children[i].copy(
destination.getChild(children[i].getName()), options, Policy.subMonitorFor(monitor, 1));
} finally {
monitor.done();
}
}
示例13: copyFile
import org.eclipse.core.filesystem.IFileInfo; //导入依赖的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();
}
}
示例14: fetchInfo
import org.eclipse.core.filesystem.IFileInfo; //导入依赖的package包/类
/**
* The default implementation of {@link IFileStore#fetchInfo()}. This implementation forwards to
* {@link IFileStore#fetchInfo(int, IProgressMonitor)}. Subclasses may override this method.
*/
public IFileInfo fetchInfo() {
try {
return fetchInfo(EFS.NONE, null);
} catch (CoreException e) {
// there was an error contacting the file system, so treat it as non-existent file
FileInfo result = new FileInfo(getName());
result.setExists(false);
return result;
}
}
示例15: fetchInfo
import org.eclipse.core.filesystem.IFileInfo; //导入依赖的package包/类
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;
}