當前位置: 首頁>>代碼示例>>Java>>正文


Java EFS.SHALLOW屬性代碼示例

本文整理匯總了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;
}
 
開發者ID:apicloudcom,項目名稱:APICloud-Studio,代碼行數:19,代碼來源:WorkspaceFile.java

示例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();
  }
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:42,代碼來源:FileStore.java

示例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;
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:13,代碼來源:LocalFile.java

示例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$
    }
  }
}
 
開發者ID:jbosstools,項目名稱:chromedevtools,代碼行數:36,代碼來源:ChromiumScriptStorage.java

示例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();
	}
}
 
開發者ID:apicloudcom,項目名稱:APICloud-Studio,代碼行數:71,代碼來源:BaseConnectionFileManager.java


注:本文中的org.eclipse.core.filesystem.EFS.SHALLOW屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。