summaryrefslogtreecommitdiffstats
path: root/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/filesystem/OEFileSystem.java
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/filesystem/OEFileSystem.java')
-rw-r--r--plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/filesystem/OEFileSystem.java103
1 files changed, 103 insertions, 0 deletions
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/filesystem/OEFileSystem.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/filesystem/OEFileSystem.java
new file mode 100644
index 0000000..a9712d3
--- /dev/null
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/filesystem/OEFileSystem.java
@@ -0,0 +1,103 @@
1/*****************************************************************************
2 * Copyright (c) 2013 Ken Gilmer, Intel Corporation
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * Ken Gilmer - initial API and implementation
10 * Ioana Grigoropol (Intel) - adapt class for remote support
11 *******************************************************************************/
12package org.yocto.bc.ui.filesystem;
13
14import java.io.File;
15import java.lang.reflect.InvocationTargetException;
16import java.net.URI;
17import java.util.ArrayList;
18import java.util.Hashtable;
19import java.util.List;
20import java.util.Map;
21
22import org.eclipse.core.filesystem.IFileStore;
23import org.eclipse.core.filesystem.IFileSystem;
24import org.eclipse.core.filesystem.provider.FileSystem;
25import org.eclipse.core.runtime.CoreException;
26import org.eclipse.core.runtime.NullProgressMonitor;
27import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
28import org.yocto.bc.bitbake.BBSession;
29import org.yocto.bc.ui.Activator;
30import org.yocto.bc.ui.model.ProjectInfo;
31
32/**
33 * A filesystem that ignores specific OE directories that contain derived information.
34 * @author kgilmer
35 *
36 */
37public class OEFileSystem extends FileSystem {
38
39 private static IFileSystem ref;
40 private ProjectInfo projInfo;
41
42 public static IFileSystem getInstance() {
43 return ref;
44 }
45
46 private Map fileStoreCache;
47
48 public OEFileSystem() {
49 ref = this;
50 fileStoreCache = new Hashtable();
51 }
52
53 @Override
54 public IFileStore getStore(URI uri) {
55
56 OEFile uf = (OEFile) fileStoreCache.get(uri);
57 setProjInfo(uri);
58
59 if (uf == null) {
60 BBSession config = null;
61 try {
62 config = Activator.getBBSession(projInfo, new NullProgressMonitor());
63 config.initialize();
64 } catch (Exception e) {
65 return new CustomLocalFile(projInfo.getProjectName(), new File(uri.getPath()));
66 }
67
68 if (config.get("TMPDIR") == null || config.get("DL_DIR") == null || config.get("SSTATE_DIR")== null) {
69 throw new RuntimeException("Invalid local.conf: TMPDIR or DL_DIR or SSTATE_DIR undefined.");
70 }
71
72 List ignoreList = new ArrayList();
73
74 //These directories are ignored because they contain too many files for Eclipse to handle efficiently.
75 ignoreList.add(config.get("TMPDIR"));
76 ignoreList.add(config.get("DL_DIR"));
77 ignoreList.add(config.get("SSTATE_DIR"));
78
79 //FIXME: add project info
80 try {
81 uf = new OEFile(uri, ignoreList, uri, projInfo, new NullProgressMonitor());
82 fileStoreCache.put(uri, uf);
83 } catch (SystemMessageException e) {
84 e.printStackTrace();
85 }
86 }
87
88 return uf;
89 }
90
91 private void setProjInfo(URI uri) {
92 try {
93 if(projInfo == null)
94 projInfo = Activator.getProjInfo(uri);
95 } catch (CoreException e) {
96 e.printStackTrace();
97 } catch (InvocationTargetException e) {
98 e.printStackTrace();
99 } catch (InterruptedException e) {
100 e.printStackTrace();
101 }
102 }
103}