summaryrefslogtreecommitdiffstats
path: root/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/filesystem
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/filesystem')
-rw-r--r--plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/filesystem/CustomLocalFile.java13
-rw-r--r--plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/filesystem/Messages.java48
-rw-r--r--plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/filesystem/OEFile.java375
-rw-r--r--plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/filesystem/OEFileSystem.java103
-rw-r--r--plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/filesystem/OEFileSystemContributor.java34
-rw-r--r--plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/filesystem/OEIgnoreFile.java135
-rw-r--r--plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/filesystem/Policy.java108
-rwxr-xr-xplugins/org.yocto.bc.ui/src/org/yocto/bc/ui/filesystem/YoctoLocation.java44
8 files changed, 860 insertions, 0 deletions
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/filesystem/CustomLocalFile.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/filesystem/CustomLocalFile.java
new file mode 100644
index 0000000..b62a1da
--- /dev/null
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/filesystem/CustomLocalFile.java
@@ -0,0 +1,13 @@
1package org.yocto.bc.ui.filesystem;
2
3import java.io.File;
4
5import org.eclipse.core.internal.filesystem.local.LocalFile;
6import org.yocto.remote.utils.RemoteHelper;
7
8public class CustomLocalFile extends LocalFile{
9
10 public CustomLocalFile(String projName, File file) {
11 super(new File(RemoteHelper.retrieveProjRootFromMetaArea(projName)));
12 }
13}
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/filesystem/Messages.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/filesystem/Messages.java
new file mode 100644
index 0000000..0a82fdd
--- /dev/null
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/filesystem/Messages.java
@@ -0,0 +1,48 @@
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 *******************************************************************************/
11package org.yocto.bc.ui.filesystem;
12
13import org.eclipse.osgi.util.NLS;
14
15/**
16 * Provides translatable messages for the file system bundle
17 */
18public class Messages extends NLS {
19 private static final String BUNDLE_NAME = "org.eclipse.core.internal.filesystem.messages"; //$NON-NLS-1$
20
21 public static String copying;
22 public static String couldnotDelete;
23 public static String couldnotDeleteReadOnly;
24 public static String couldNotLoadLibrary;
25 public static String couldNotMove;
26 public static String couldNotRead;
27 public static String couldNotWrite;
28 public static String deleteProblem;
29 public static String deleting;
30 public static String failedCreateWrongType;
31 public static String failedMove;
32 public static String failedReadDuringWrite;
33 public static String fileExists;
34 public static String fileNotFound;
35 public static String moving;
36 public static String noFileSystem;
37 public static String noImplDelete;
38 public static String noImplWrite;
39 public static String noScheme;
40 public static String notAFile;
41 public static String readOnlyParent;
42
43 static {
44 // initialize resource bundles
45 NLS.initializeMessages(BUNDLE_NAME, Messages.class);
46 }
47
48}
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/filesystem/OEFile.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/filesystem/OEFile.java
new file mode 100644
index 0000000..afcd372
--- /dev/null
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/filesystem/OEFile.java
@@ -0,0 +1,375 @@
1/*******************************************************************************
2 * Copyright (c) 2005, 2006 IBM Corporation, 2013 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 * IBM Corporation - initial API and implementation
10 * Ken Gilmer - adaptation from internal class.
11 * Ioana Grigoropol (Intel) - adapt class for remote support
12 *******************************************************************************/
13package org.yocto.bc.ui.filesystem;
14
15import java.io.File;
16import java.io.FileInputStream;
17import java.io.FileNotFoundException;
18import java.io.FileOutputStream;
19import java.io.IOException;
20import java.io.InputStream;
21import java.io.OutputStream;
22import java.net.URI;
23import java.util.List;
24
25import org.eclipse.core.filesystem.EFS;
26import org.eclipse.core.filesystem.IFileInfo;
27import org.eclipse.core.filesystem.IFileStore;
28import org.eclipse.core.filesystem.IFileSystem;
29import org.eclipse.core.filesystem.URIUtil;
30import org.eclipse.core.filesystem.provider.FileInfo;
31import org.eclipse.core.filesystem.provider.FileStore;
32import org.eclipse.core.runtime.CoreException;
33import org.eclipse.core.runtime.IPath;
34import org.eclipse.core.runtime.IProgressMonitor;
35import org.eclipse.core.runtime.IStatus;
36import org.eclipse.core.runtime.MultiStatus;
37import org.eclipse.core.runtime.NullProgressMonitor;
38import org.eclipse.core.runtime.Status;
39import org.eclipse.osgi.util.NLS;
40import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
41import org.eclipse.rse.services.files.IFileService;
42import org.eclipse.rse.services.files.IHostFile;
43import org.yocto.bc.bitbake.BBSession;
44import org.yocto.bc.bitbake.ProjectInfoHelper;
45import org.yocto.bc.bitbake.ShellSession;
46import org.yocto.bc.ui.Activator;
47import org.yocto.bc.ui.model.ProjectInfo;
48import org.yocto.bc.ui.model.YoctoHostFile;
49
50/**
51 * File system implementation based on storage of files in the local
52 * operating system's file system.
53 */
54public class OEFile extends FileStore {
55 private static int attributes(File aFile) {
56 if (!aFile.exists() || aFile.canWrite())
57 return EFS.NONE;
58 return EFS.ATTRIBUTE_READ_ONLY;
59 }
60
61
62 protected final YoctoHostFile file;
63
64 private List<Object> ignoredPaths;
65
66 /**
67 * The absolute file system path of the file represented by this store.
68 */
69 protected final String filePath;
70
71 private final URI root;
72
73 /**
74 * Creates a new local file.
75 *
76 * @param file The file this local file represents
77 * @param root
78 */
79 public OEFile(URI fileURI, List<Object> ignoredPaths, URI root, ProjectInfo projInfo, IProgressMonitor monitor) throws SystemMessageException {
80 this.ignoredPaths = ignoredPaths;
81 this.root = root;
82 this.file = new YoctoHostFile(projInfo, fileURI, monitor);
83 this.filePath = file.getAbsolutePath();
84 }
85
86 @Override
87 public String[] childNames(int options, IProgressMonitor monitor) {
88 return file.getChildNames(monitor);
89 }
90
91 /*
92 * detect if the path is potential builddir
93 */
94 private boolean isPotentialBuildDir(String path) {
95 String parentPath = path.substring(0, path.lastIndexOf("/"));
96 String name = path.substring(path.lastIndexOf("/") + 1);
97 boolean ret = true;
98 try {
99 IFileService fs = file.getFileService();
100 IHostFile hostFile = fs.getFile(parentPath, name, new NullProgressMonitor());
101 if (!hostFile.isDirectory())
102 return false;
103 IHostFile confDir = fs.getFile(path, BBSession.CONF_DIR, new NullProgressMonitor());
104 if (!confDir.exists() || !confDir.isDirectory())
105 return false;
106 for (int i = 0; i < BBSession.BUILDDIR_INDICATORS.length && ret == true; i++) {
107 IHostFile child = fs.getFile(path + "/" + BBSession.CONF_DIR, BBSession.BUILDDIR_INDICATORS[i], new NullProgressMonitor());
108 if(!child.exists() || !child.isFile()) {
109 ret = false;
110 break;
111 }
112 }
113
114 } catch (SystemMessageException e) {
115 e.printStackTrace();
116 }
117 return ret;
118 }
119
120 /*
121 * try to find items for ignoreList
122 */
123 private void updateIgnorePaths(String path, List<Object> list, IProgressMonitor monitor) {
124 if(isPotentialBuildDir(path)) {
125 BBSession config = null;
126 try {
127 config = Activator.getBBSession(Activator.getProjInfo(root), monitor);
128 config.initialize();
129 } catch(Exception e) {
130 e.printStackTrace();
131 return;
132 }
133 if (config.get("TMPDIR") == null || config.get("DL_DIR") == null || config.get("SSTATE_DIR") == null) {
134 //wrong guess about the buildDir
135 return;
136 }else {
137 if(!list.contains(config.get("TMPDIR"))) {
138 list.add(config.get("TMPDIR"));
139 }
140 if(!list.contains(config.get("DL_DIR"))) {
141 list.add(config.get("DL_DIR"));
142 }
143 if(!list.contains(config.get("SSTATE_DIR"))) {
144 list.add(config.get("SSTATE_DIR"));
145 }
146 }
147 }
148 }
149
150 @Override
151 public IFileStore[] childStores(int options, IProgressMonitor monitor) throws CoreException {
152 String[] children = childNames(options, monitor);
153 IFileStore[] wrapped = new IFileStore[children.length];
154
155 for (int i = 0; i < wrapped.length; i++) {
156 String fullPath = file.getAbsolutePath() + "/" + children[i];
157 updateIgnorePaths(fullPath, ignoredPaths, monitor);
158 if (ignoredPaths.contains(fullPath)) {
159 wrapped[i] = getDeadChild(children[i]);
160 } else {
161 wrapped[i] = getChild(children[i]);
162 }
163 }
164
165 return wrapped;
166 }
167
168 @Override
169 public void copy(IFileStore destFileStore, int options, IProgressMonitor monitor) throws CoreException {
170 if (destFileStore instanceof OEFile) {
171 file.copy(destFileStore, monitor);
172 }
173 }
174
175 @Override
176 public void delete(int options, IProgressMonitor monitor) throws CoreException {
177 if (monitor == null)
178 monitor = new NullProgressMonitor();
179 else
180 monitor = new NullProgressMonitor();
181 try {
182 monitor.beginTask(NLS.bind(Messages.deleting, this), 200);
183 String message = Messages.deleteProblem;
184 MultiStatus result = new MultiStatus(Policy.PI_FILE_SYSTEM, EFS.ERROR_DELETE, message, null);
185
186 //don't allow Eclipse to delete entire OE directory
187
188 if (!isProject()) {
189 internalDelete(file, filePath, result, monitor);
190 }
191
192 if (!result.isOK())
193 throw new CoreException(result);
194 } finally {
195 monitor.done();
196 }
197 }
198
199 @Override
200 public boolean equals(Object obj) {
201 if (!(obj instanceof OEFile))
202 return false;
203
204 OEFile otherFile = (OEFile) obj;
205
206 return file.equals(otherFile.file);
207 }
208
209 @Override
210 public IFileInfo fetchInfo(int options, IProgressMonitor monitor) {
211 //in-lined non-native implementation
212 FileInfo info = new FileInfo(file.getName());
213 final long lastModified = file.getModifiedDate();
214 if (lastModified <= 0) {
215 //if the file doesn't exist, all other attributes should be default values
216 info.setExists(false);
217 return info;
218 }
219 info.setLastModified(lastModified);
220 info.setExists(true);
221 info.setLength(file.getSize());
222 info.setDirectory(file.isDirectory());
223 info.setAttribute(EFS.ATTRIBUTE_READ_ONLY, file.exists() && !file.canWrite());
224 info.setAttribute(EFS.ATTRIBUTE_HIDDEN, file.isHidden());
225 return info;
226 }
227
228 @Override
229 public IFileStore getChild(IPath path) {
230 try {
231 return new OEFile(file.getChildURIformPath(path), ignoredPaths, root, file.getProjectInfo(), new NullProgressMonitor());
232 } catch (SystemMessageException e) {
233 e.printStackTrace();
234 return null;
235 }
236 }
237
238 @Override
239 public IFileStore getChild(String name) {
240
241 try {
242 return new OEFile(file.getChildURI(name), ignoredPaths, root, file.getProjectInfo(), new NullProgressMonitor());
243 } catch (SystemMessageException e) {
244 e.printStackTrace();
245 }
246 return null;
247
248 }
249
250 private IFileStore getDeadChild(String name) {
251 return new OEIgnoreFile(file.getChildHostFile(name));
252 }
253
254 /*
255 * (non-Javadoc)
256 * @see org.eclipse.core.filesystem.IFileStore#getFileSystem()
257 */
258 @Override
259 public IFileSystem getFileSystem() {
260 return OEFileSystem.getInstance();
261 }
262
263 @Override
264 public String getName() {
265 return file.getName();
266 }
267
268 @Override
269 public IFileStore getParent() {
270 URI parentURI = file.getParentFile();
271 try {
272 return parentURI == null ? null : new OEFile(parentURI, ignoredPaths, root, file.getProjectInfo(), new NullProgressMonitor());
273 } catch (SystemMessageException e) {
274 e.printStackTrace();
275 return null;
276 }
277 }
278
279 @Override
280 public int hashCode() {
281 return file.hashCode();
282 }
283
284 /**
285 * Deletes the given file recursively, adding failure info to
286 * the provided status object. The filePath is passed as a parameter
287 * to optimize java.io.File object creation.
288 */
289 private boolean internalDelete(YoctoHostFile target, String pathToDelete, MultiStatus status, IProgressMonitor monitor) {
290 target.delete(monitor);
291 return false;
292 }
293
294 @Override
295 public boolean isParentOf(IFileStore other) {
296 if (!(other instanceof OEFile))
297 return false;
298 String thisPath = filePath;
299 String thatPath = ((OEFile) other).filePath;
300 int thisLength = thisPath.length();
301 int thatLength = thatPath.length();
302 //if equal then not a parent
303 if (thisLength >= thatLength)
304 return false;
305 if (getFileSystem().isCaseSensitive()) {
306 if (thatPath.indexOf(thisPath) != 0)
307 return false;
308 } else {
309 if (thatPath.toLowerCase().indexOf(thisPath.toLowerCase()) != 0)
310 return false;
311 }
312 //The common portion must end with a separator character for this to be a parent of that
313 return thisPath.charAt(thisLength - 1) == File.separatorChar || thatPath.charAt(thisLength) == File.separatorChar;
314 }
315
316 /**
317 * @return
318 */
319 private boolean isProject() {
320 return this.file.toString().equals(root);
321 }
322
323 @Override
324 public IFileStore mkdir(int options, IProgressMonitor monitor) throws CoreException {
325 file.mkdir(options);
326 return this;
327 }
328
329 @Override
330 public void move(IFileStore destFile, int options, IProgressMonitor monitor) throws CoreException {
331 file.move(destFile, monitor);
332 }
333
334 @Override
335 public InputStream openInputStream(int options, IProgressMonitor monitor) throws CoreException {
336 return file.getInputStream(options, monitor);
337 }
338
339 @Override
340 public OutputStream openOutputStream(int options, IProgressMonitor monitor) throws CoreException {
341 return file.getOutputStream(options, monitor);
342 }
343
344 @Override
345 public void putInfo(IFileInfo info, int options, IProgressMonitor monitor) throws CoreException {
346 file.putInfo(info, options, monitor);
347 }
348
349 /* (non-Javadoc)
350 * @see org.eclipse.core.filesystem.provider.FileStore#toLocalFile(int, org.eclipse.core.runtime.IProgressMonitor)
351 */
352 @Override
353 public File toLocalFile(int options, IProgressMonitor monitor) throws CoreException {
354 return file.toLocalFile();
355 }
356
357 /* (non-Javadoc)
358 * @see org.eclipse.core.filesystem.IFileStore#toString()
359 */
360 @Override
361 public String toString() {
362 return file.toString();
363 }
364
365 /* (non-Javadoc)
366 * @see org.eclipse.core.filesystem.IFileStore#toURI()
367 */
368 @Override
369 public URI toURI() {
370 return URIUtil.toURI(filePath);
371 }
372 public String getParentPath() {
373 return filePath.substring(0, filePath.lastIndexOf("/"));
374 }
375}
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}
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/filesystem/OEFileSystemContributor.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/filesystem/OEFileSystemContributor.java
new file mode 100644
index 0000000..cfff7d6
--- /dev/null
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/filesystem/OEFileSystemContributor.java
@@ -0,0 +1,34 @@
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) - initial API and implementation
11 *******************************************************************************/
12package org.yocto.bc.ui.filesystem;
13
14import java.net.URI;
15
16import org.eclipse.swt.widgets.Shell;
17import org.eclipse.ui.ide.fileSystem.FileSystemContributor;
18
19public class OEFileSystemContributor extends FileSystemContributor {
20
21 public OEFileSystemContributor() {
22 }
23
24 @Override
25 public URI browseFileSystem(String initialPath, Shell shell) {
26 return null;
27 }
28
29 @Override
30 public URI getURI(String string) {
31 return super.getURI(string);
32 }
33
34}
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/filesystem/OEIgnoreFile.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/filesystem/OEIgnoreFile.java
new file mode 100644
index 0000000..2434347
--- /dev/null
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/filesystem/OEIgnoreFile.java
@@ -0,0 +1,135 @@
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.io.InputStream;
16import java.io.OutputStream;
17import java.net.URI;
18
19import org.eclipse.core.filesystem.IFileInfo;
20import org.eclipse.core.filesystem.IFileStore;
21import org.eclipse.core.filesystem.IFileSystem;
22import org.eclipse.core.filesystem.provider.FileInfo;
23import org.eclipse.core.runtime.CoreException;
24import org.eclipse.core.runtime.IPath;
25import org.eclipse.core.runtime.IProgressMonitor;
26import org.yocto.bc.ui.model.YoctoHostFile;
27
28public class OEIgnoreFile implements IFileStore {
29
30 private final YoctoHostFile file;
31
32 public OEIgnoreFile(YoctoHostFile file) {
33 this.file = file;
34 }
35
36 public IFileInfo[] childInfos(int options, IProgressMonitor monitor) throws CoreException {
37
38 return new IFileInfo[0];
39 }
40
41 public String[] childNames(int options, IProgressMonitor monitor) throws CoreException {
42 return new String[0];
43 }
44
45 public IFileStore[] childStores(int options, IProgressMonitor monitor) throws CoreException {
46
47 return new IFileStore[0];
48 }
49
50 public void copy(IFileStore destination, int options, IProgressMonitor monitor) throws CoreException {
51 // TODO Auto-generated method stub
52
53 }
54
55 public void delete(int options, IProgressMonitor monitor) throws CoreException {
56 // TODO Auto-generated method stub
57
58 }
59
60 public IFileInfo fetchInfo() {
61 // TODO Auto-generated method stub
62 return new FileInfo(file.getName());
63 }
64
65 public IFileInfo fetchInfo(int options, IProgressMonitor monitor) throws CoreException {
66 return new FileInfo(file.getName());
67 }
68
69 public Object getAdapter(Class adapter) {
70 // TODO Auto-generated method stub
71 return null;
72 }
73
74 public IFileStore getChild(IPath path) {
75 // TODO Auto-generated method stub
76 return null;
77 }
78
79
80
81 public IFileStore getChild(String name) {
82 return null;
83 }
84
85 public IFileSystem getFileSystem() {
86 // TODO Auto-generated method stub
87 return OEFileSystem.getInstance();
88 }
89
90 public String getName() {
91 return file.getName();
92 }
93
94 public IFileStore getParent() {
95 // TODO Auto-generated method stub
96 return null;
97 }
98
99 public boolean isParentOf(IFileStore other) {
100 // TODO Auto-generated method stub
101 return false;
102 }
103
104 public IFileStore mkdir(int options, IProgressMonitor monitor) throws CoreException {
105 return null;
106 }
107
108 public void move(IFileStore destination, int options, IProgressMonitor monitor) throws CoreException {
109 }
110
111 public InputStream openInputStream(int options, IProgressMonitor monitor) throws CoreException {
112 return null;
113 }
114
115 public OutputStream openOutputStream(int options, IProgressMonitor monitor) throws CoreException {
116 return null;
117 }
118
119 public void putInfo(IFileInfo info, int options, IProgressMonitor monitor) throws CoreException {
120 }
121
122 public File toLocalFile(int options, IProgressMonitor monitor) throws CoreException {
123 return file.toLocalFile();
124 }
125
126 public URI toURI() {
127 return file.toURI();
128 }
129
130 public IFileStore getFileStore(IPath path) {
131 return null;
132 }
133
134
135}
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/filesystem/Policy.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/filesystem/Policy.java
new file mode 100644
index 0000000..84c0f32
--- /dev/null
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/filesystem/Policy.java
@@ -0,0 +1,108 @@
1/*******************************************************************************
2 * Copyright (c) 2000, 2007 IBM Corporation and others.
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 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11package org.yocto.bc.ui.filesystem;
12
13import java.io.IOException;
14import java.io.InputStream;
15import java.io.OutputStream;
16import java.util.Date;
17
18import org.eclipse.core.runtime.CoreException;
19import org.eclipse.core.runtime.IProgressMonitor;
20import org.eclipse.core.runtime.NullProgressMonitor;
21import org.eclipse.core.runtime.OperationCanceledException;
22import org.eclipse.core.runtime.Status;
23import org.eclipse.core.runtime.SubProgressMonitor;
24
25import org.yocto.bc.ui.Activator;
26
27/**
28 * Grab bag of utility methods for the file system plugin
29 */
30public class Policy {
31
32 /**
33 * General debug flag for the plugin
34 */
35 public static boolean DEBUG = false;
36
37 public static final String PI_FILE_SYSTEM = "org.eclipse.core.filesystem"; //$NON-NLS-1$
38
39 public static void checkCanceled(IProgressMonitor monitor) {
40 if (monitor.isCanceled())
41 throw new OperationCanceledException();
42 }
43
44 /**
45 * Print a debug message to the console.
46 * Pre-pend the message with the current date and the name of the current thread.
47 */
48 public static void debug(String message) {
49 StringBuffer buffer = new StringBuffer();
50 buffer.append(new Date(System.currentTimeMillis()));
51 buffer.append(" - ["); //$NON-NLS-1$
52 buffer.append(Thread.currentThread().getName());
53 buffer.append("] "); //$NON-NLS-1$
54 buffer.append(message);
55 System.out.println(buffer.toString());
56 }
57
58 public static void error(int code, String message) throws CoreException {
59 error(code, message, null);
60 }
61
62 public static void error(int code, String message, Throwable exception) throws CoreException {
63 int severity = code == 0 ? 0 : 1 << (code % 100 / 33);
64 throw new CoreException(new Status(severity, PI_FILE_SYSTEM, code, message, exception));
65 }
66
67 public static void log(int severity, String message, Throwable t) {
68 if (message == null)
69 message = ""; //$NON-NLS-1$
70 Activator.getDefault().getLog().log(new Status(severity, PI_FILE_SYSTEM, 1, message, t));
71 }
72
73 public static IProgressMonitor monitorFor(IProgressMonitor monitor) {
74 return monitor == null ? new NullProgressMonitor() : monitor;
75 }
76
77 /**
78 * Closes a stream and ignores any resulting exception.
79 */
80 public static void safeClose(InputStream in) {
81 try {
82 if (in != null)
83 in.close();
84 } catch (IOException e) {
85 //ignore
86 }
87 }
88
89 /**
90 * Closes a stream and ignores any resulting exception.
91 */
92 public static void safeClose(OutputStream out) {
93 try {
94 if (out != null)
95 out.close();
96 } catch (IOException e) {
97 //ignore
98 }
99 }
100
101 public static IProgressMonitor subMonitorFor(IProgressMonitor monitor, int ticks) {
102 if (monitor == null)
103 return new NullProgressMonitor();
104 if (monitor instanceof NullProgressMonitor)
105 return monitor;
106 return new SubProgressMonitor(monitor, ticks);
107 }
108}
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/filesystem/YoctoLocation.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/filesystem/YoctoLocation.java
new file mode 100755
index 0000000..40d9345
--- /dev/null
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/filesystem/YoctoLocation.java
@@ -0,0 +1,44 @@
1/*******************************************************************************
2 * Copyright (c) 2013 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 * Ioana Grigoropol(Intel) - initial API and implementation
10 *******************************************************************************/
11package org.yocto.bc.ui.filesystem;
12
13import java.net.URI;
14import java.net.URISyntaxException;
15
16public class YoctoLocation{
17 URI oefsURI;
18 URI originalURI;
19
20 public YoctoLocation(){
21 try {
22 oefsURI = new URI("");
23 originalURI = new URI("");
24 } catch (URISyntaxException e) {
25 e.printStackTrace();
26 }
27 }
28
29 public URI getOEFSURI() {
30 return oefsURI;
31 }
32
33 public URI getOriginalURI() {
34 return originalURI;
35 }
36
37 public void setOriginalURI(URI originalURI) {
38 this.originalURI = originalURI;
39 }
40
41 public void setOEFSURI(URI uri) {
42 this.oefsURI = uri;
43 }
44}