Java Code Examples for org.eclipse.core.filesystem.IFileStore#childNames()

The following examples show how to use org.eclipse.core.filesystem.IFileStore#childNames() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ClientExport.java    From orion.server with Eclipse Public License 1.0 6 votes vote down vote up
public void doExport(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException {
	IFileStore source = NewFileServlet.getFileStore(req, sourcePath);
	if (req.getParameter(ProtocolConstants.PARAM_EXCLUDE) != null) {
		excludedFiles = Arrays.asList(req.getParameter(ProtocolConstants.PARAM_EXCLUDE).split(","));
	}

	try {
		if (source.fetchInfo(EFS.NONE, null).isDirectory() && source.childNames(EFS.NONE, null).length == 0) {
			resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "You cannot export an empty folder");
			return;
		}

		resp.setHeader("Cache-Control", "no-cache"); //$NON-NLS-1$ //$NON-NLS-2$
		ZipOutputStream zout = new ZipOutputStream(resp.getOutputStream());
		write(source, Path.EMPTY, zout);
		zout.finish();
	} catch (CoreException e) {
		//we can't return an error response at this point because the output stream has been used
		throw new ServletException(e);
	}
}
 
Example 2
Source File: TransferResourceDecorator.java    From orion.server with Eclipse Public License 1.0 5 votes vote down vote up
private boolean isEmptyDirectory(HttpServletRequest request, IPath targetPath) {
	IFileStore store = NewFileServlet.getFileStore(request, targetPath);
	//if an error occurred we can't tell, so assume non-empty to be safe
	if (store == null) {
		return false;
	}
	try {
		return store.childNames(EFS.NONE, null).length == 0;
	} catch (CoreException e) {
		//this isn't the place for reporting this failure, so assume non-empty
		return false;
	}
}