From c7da892cb23d50d4d85746c9a0b6b14bf570989d Mon Sep 17 00:00:00 2001 From: Adrian Dudau Date: Thu, 26 Jun 2014 13:23:09 +0200 Subject: initial commit for Enea Linux 4.0 Migrated from the internal git server on the daisy-enea branch Signed-off-by: Adrian Dudau --- .../org/yocto/bc/ui/filesystem/OEFileSystem.java | 103 +++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/filesystem/OEFileSystem.java (limited to 'plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/filesystem/OEFileSystem.java') 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 @@ +/***************************************************************************** + * Copyright (c) 2013 Ken Gilmer, Intel Corporation + * 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: + * Ken Gilmer - initial API and implementation + * Ioana Grigoropol (Intel) - adapt class for remote support + *******************************************************************************/ +package org.yocto.bc.ui.filesystem; + +import java.io.File; +import java.lang.reflect.InvocationTargetException; +import java.net.URI; +import java.util.ArrayList; +import java.util.Hashtable; +import java.util.List; +import java.util.Map; + +import org.eclipse.core.filesystem.IFileStore; +import org.eclipse.core.filesystem.IFileSystem; +import org.eclipse.core.filesystem.provider.FileSystem; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.rse.services.clientserver.messages.SystemMessageException; +import org.yocto.bc.bitbake.BBSession; +import org.yocto.bc.ui.Activator; +import org.yocto.bc.ui.model.ProjectInfo; + +/** + * A filesystem that ignores specific OE directories that contain derived information. + * @author kgilmer + * + */ +public class OEFileSystem extends FileSystem { + + private static IFileSystem ref; + private ProjectInfo projInfo; + + public static IFileSystem getInstance() { + return ref; + } + + private Map fileStoreCache; + + public OEFileSystem() { + ref = this; + fileStoreCache = new Hashtable(); + } + + @Override + public IFileStore getStore(URI uri) { + + OEFile uf = (OEFile) fileStoreCache.get(uri); + setProjInfo(uri); + + if (uf == null) { + BBSession config = null; + try { + config = Activator.getBBSession(projInfo, new NullProgressMonitor()); + config.initialize(); + } catch (Exception e) { + return new CustomLocalFile(projInfo.getProjectName(), new File(uri.getPath())); + } + + if (config.get("TMPDIR") == null || config.get("DL_DIR") == null || config.get("SSTATE_DIR")== null) { + throw new RuntimeException("Invalid local.conf: TMPDIR or DL_DIR or SSTATE_DIR undefined."); + } + + List ignoreList = new ArrayList(); + + //These directories are ignored because they contain too many files for Eclipse to handle efficiently. + ignoreList.add(config.get("TMPDIR")); + ignoreList.add(config.get("DL_DIR")); + ignoreList.add(config.get("SSTATE_DIR")); + + //FIXME: add project info + try { + uf = new OEFile(uri, ignoreList, uri, projInfo, new NullProgressMonitor()); + fileStoreCache.put(uri, uf); + } catch (SystemMessageException e) { + e.printStackTrace(); + } + } + + return uf; + } + + private void setProjInfo(URI uri) { + try { + if(projInfo == null) + projInfo = Activator.getProjInfo(uri); + } catch (CoreException e) { + e.printStackTrace(); + } catch (InvocationTargetException e) { + e.printStackTrace(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } +} -- cgit v1.2.3-54-g00ecf