diff options
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.java | 78 |
1 files changed, 78 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..f0bf449 --- /dev/null +++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/filesystem/OEFileSystem.java | |||
@@ -0,0 +1,78 @@ | |||
1 | /***************************************************************************** | ||
2 | * Copyright (c) 2009 Ken Gilmer | ||
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 | *******************************************************************************/ | ||
11 | package org.yocto.bc.ui.filesystem; | ||
12 | |||
13 | import java.io.File; | ||
14 | import java.net.URI; | ||
15 | import java.util.ArrayList; | ||
16 | import java.util.Hashtable; | ||
17 | import java.util.List; | ||
18 | import java.util.Map; | ||
19 | |||
20 | import org.eclipse.core.filesystem.IFileStore; | ||
21 | import org.eclipse.core.filesystem.IFileSystem; | ||
22 | import org.eclipse.core.filesystem.provider.FileSystem; | ||
23 | |||
24 | import org.yocto.bc.bitbake.BBSession; | ||
25 | import org.yocto.bc.ui.Activator; | ||
26 | |||
27 | /** | ||
28 | * A filesystem that ignores specific OE directories that contain derived information. | ||
29 | * @author kgilmer | ||
30 | * | ||
31 | */ | ||
32 | public class OEFileSystem extends FileSystem { | ||
33 | |||
34 | private static IFileSystem ref; | ||
35 | public static IFileSystem getInstance() { | ||
36 | return ref; | ||
37 | } | ||
38 | |||
39 | private Map fileStoreCache; | ||
40 | |||
41 | public OEFileSystem() { | ||
42 | ref = this; | ||
43 | fileStoreCache = new Hashtable(); | ||
44 | } | ||
45 | |||
46 | @Override | ||
47 | public IFileStore getStore(URI uri) { | ||
48 | |||
49 | OEFile uf = (OEFile) fileStoreCache.get(uri); | ||
50 | |||
51 | if (uf == null) { | ||
52 | BBSession config = null; | ||
53 | try { | ||
54 | config = Activator.getBBSession(uri.getPath()); | ||
55 | config.initialize(); | ||
56 | } catch (Exception e) { | ||
57 | e.printStackTrace(); | ||
58 | return new OEIgnoreFile(new File(uri.getPath())); | ||
59 | } | ||
60 | |||
61 | if (config.get("TMPDIR") == null || config.get("DL_DIR") == null || config.get("SSTATE_DIR")== null) { | ||
62 | throw new RuntimeException("Invalid local.conf: TMPDIR or DL_DIR or SSTATE_DIR undefined."); | ||
63 | } | ||
64 | |||
65 | List ignoreList = new ArrayList(); | ||
66 | |||
67 | //These directories are ignored because they contain too many files for Eclipse to handle efficiently. | ||
68 | ignoreList.add(config.get("TMPDIR")); | ||
69 | ignoreList.add(config.get("DL_DIR")); | ||
70 | ignoreList.add(config.get("SSTATE_DIR")); | ||
71 | |||
72 | uf = new OEFile(new File(uri.getPath()), ignoreList, uri.getPath()); | ||
73 | fileStoreCache.put(uri, uf); | ||
74 | } | ||
75 | |||
76 | return uf; | ||
77 | } | ||
78 | } | ||