本文整理汇总了Java中org.eclipse.core.filesystem.EFS.SHALLOW属性的典型用法代码示例。如果您正苦于以下问题:Java EFS.SHALLOW属性的具体用法?Java EFS.SHALLOW怎么用?Java EFS.SHALLOW使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.eclipse.core.filesystem.EFS
的用法示例。
在下文中一共展示了EFS.SHALLOW属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mkdir
@Override
public IFileStore mkdir(int options, IProgressMonitor monitor) throws CoreException {
ensureLocalFileStore(IFolder.class);
if (resource != null && !resource.exists()) {
monitor = Policy.monitorFor(monitor);
monitor.beginTask(MessageFormat.format("Creating folder {0}", path.lastSegment()), 100); //$NON-NLS-1$
try {
if ((options & EFS.SHALLOW) == 0) {
createParentsRecursive(resource, Policy.subMonitorFor(monitor, 80));
} else {
Policy.subMonitorFor(monitor, 80).done();
}
((IFolder) resource).create(IResource.FORCE, true, Policy.subMonitorFor(monitor, 20));
} catch (CoreException e) {
fileNotFoundError(e, path);
}
}
return this;
}
示例2: copyDirectory
/**
* 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();
}
}
示例3: mkdir
public IFileStore mkdir(int options, IProgressMonitor monitor) throws CoreException {
boolean shallow = (options & EFS.SHALLOW) != 0;
// must be a directory
if (shallow) file.mkdir();
else file.mkdirs();
if (!file.isDirectory()) {
checkReadOnlyParent(file, null);
checkTargetIsNotWritable(file, null);
String message = NLS.bind(Messages.failedCreateWrongType, filePath);
Policy.error(EFS.ERROR_WRONG_TYPE, message);
}
return this;
}
示例4: mkdir
void mkdir(IPath path, int options) throws CoreException {
CommonNode node = find(path);
if (node != null || path.segmentCount() == 0) { // folder exists
return;
}
IPath parentPath = getParentPath(path);
// parentPath will not be null due to the check above
CommonNode parentNode = find(parentPath);
if ((options & EFS.SHALLOW) != 0) {
IPath chainPath = ROOT_PATH;
CommonNode childNode = null;
parentNode = find(ROOT_PATH);
for (int i = 0, length = path.segmentCount(); i < length; i++) {
chainPath = chainPath.append(path.segment(i));
childNode = find(chainPath);
if (childNode == null) {
createFolder(chainPath, parentNode);
parentNode = childNode;
continue;
}
if (childNode.isFile()) {
throw newCoreException("File encountered in the path: " + chainPath, null); //$NON-NLS-1$
}
}
} else {
if (parentNode == null) {
throw newCoreException("Parent does not exist, child=" + path, null); //$NON-NLS-1$
}
// not shallow and parent exists
if (!parentNode.isFile()) {
createFolder(path, parentNode);
} else {
throw newCoreException("Parent is a file: " + parentNode.path, null); //$NON-NLS-1$
}
}
}
示例5: mkdir
public final synchronized void mkdir(IPath path, int options, IProgressMonitor monitor) throws CoreException
{
monitor = Policy.monitorFor(monitor);
monitor.beginTask(
MessageFormat.format(Messages.BaseConnectionFileManager_creating_folder, path.toPortableString()), 3);
try
{
ProgressMonitorInterrupter.setCurrentThreadInterruptDelegate(interruptDelegate);
testOrConnect(monitor);
ExtendedFileInfo fileInfo = fetchAndCacheFileInfo(path, IExtendedFileStore.EXISTENCE,
Policy.subMonitorFor(monitor, 1));
setLastOperationTime();
if (fileInfo.exists())
{
if (!fileInfo.isDirectory())
{
throw new CoreException(new Status(IStatus.ERROR, CoreIOPlugin.PLUGIN_ID,
Messages.BaseConnectionFileManager_file_already_exists, initFileNotFoundException(path,
null)));
}
return;
}
if ((options & EFS.SHALLOW) != 0 && path.segmentCount() > 1)
{
fileInfo = fetchAndCacheFileInfo(path.removeLastSegments(1), IExtendedFileStore.EXISTENCE,
Policy.subMonitorFor(monitor, 1));
setLastOperationTime();
if (!fileInfo.exists())
{
throw new CoreException(new Status(IStatus.ERROR, CoreIOPlugin.PLUGIN_ID,
Messages.BaseConnectionFileManager_parent_doesnt_exist, initFileNotFoundException(path,
null)));
}
if (!fileInfo.isDirectory())
{
throw new CoreException(new Status(IStatus.ERROR, CoreIOPlugin.PLUGIN_ID,
Messages.BaseConnectionFileManager_parent_is_not_directory, initFileNotFoundException(path,
null)));
}
createDirectory(basePath.append(path), Policy.subMonitorFor(monitor, 1));
}
else if (path.segmentCount() == 1)
{
createDirectory(basePath.append(path), Policy.subMonitorFor(monitor, 1));
}
else
{
IProgressMonitor subMonitor = Policy.subMonitorFor(monitor, 1);
subMonitor.beginTask(Messages.BaseConnectionFileManager_creating_folders, path.segmentCount());
for (int i = path.segmentCount() - 1; i >= 0; --i)
{
createDirectory(basePath.append(path).removeLastSegments(i), subMonitor);
subMonitor.worked(1);
}
subMonitor.done();
}
setLastOperationTime();
}
catch (FileNotFoundException e)
{
setLastOperationTime();
throw new CoreException(new Status(IStatus.ERROR, CoreIOPlugin.PLUGIN_ID,
Messages.BaseConnectionFileManager_parent_doesnt_exist, initFileNotFoundException(path, e)
.getCause()));
}
finally
{
ProgressMonitorInterrupter.setCurrentThreadInterruptDelegate(null);
monitor.done();
}
}