Skip to main content
summaryrefslogtreecommitdiffstats
blob: 97778c2f4c1588bc863707f00c30aa1e13466192 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/****************************************************************************
 * Copyright (c) 2007 Composent, Inc. and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    Composent, Inc. - initial API and implementation
 *****************************************************************************/

package org.eclipse.ecf.internal.provider.filetransfer.efs;

import java.net.URL;

import org.eclipse.core.filesystem.EFS;
import org.eclipse.core.filesystem.IFileInfo;
import org.eclipse.core.filesystem.IFileStore;
import org.eclipse.core.runtime.Assert;
import org.eclipse.ecf.core.util.Proxy;
import org.eclipse.ecf.filetransfer.IRemoteFile;
import org.eclipse.ecf.filetransfer.IRemoteFileSystemListener;
import org.eclipse.ecf.filetransfer.RemoteFileSystemException;
import org.eclipse.ecf.filetransfer.identity.FileIDFactory;
import org.eclipse.ecf.filetransfer.identity.IFileID;
import org.eclipse.ecf.provider.filetransfer.browse.AbstractFileSystemBrowser;


/**
 *
 */
public class FileStoreBrowser extends AbstractFileSystemBrowser {

	IFileStore fileStore;
	URL efsDirectory;

	/**
	 * @param store 
	 * @param efsDirectory 
	 * @param directoryID2 
	 * @param listener 
	 * @throws RemoteFileSystemException 
	 * 
	 */
	public FileStoreBrowser(IFileStore store, URL efsDirectory, IFileID directoryID2, IRemoteFileSystemListener listener) throws RemoteFileSystemException {
		super(directoryID2, listener);
		Assert.isNotNull(store);
		this.fileStore = store;
		Assert.isNotNull(efsDirectory);
		this.efsDirectory = efsDirectory;
	}

	/* (non-Javadoc)
	 * @see org.eclipse.ecf.provider.filetransfer.browse.LocalFileSystemBrowser#runDirectoryRequest()
	 */
	protected void runRequest() throws Exception {
		final IFileInfo fileStoreInfo = fileStore.fetchInfo();
		if (fileStoreInfo.isDirectory()) {
			final IFileInfo[] fileInfos = fileStore.childInfos(EFS.NONE, null);
			remoteFiles = new IRemoteFile[fileInfos.length];
			for (int i = 0; i < fileInfos.length; i++) {
				remoteFiles[i] = new EFSRemoteFile(FileIDFactory.getDefault().createFileID(fileID.getNamespace(), new URL(efsDirectory + "/" + fileInfos[i].getName())), fileInfos[i]); //$NON-NLS-1$
			}
		} else {
			remoteFiles = new IRemoteFile[1];
			remoteFiles[0] = new EFSRemoteFile(fileID, fileStoreInfo);
		}
	}

}

Back to the top