/* * Reads the classpath file entries of this project's .classpath file. * This includes the output entry. * As a side effect, unknown elements are stored in the given map (if not null) * Throws exceptions if the file cannot be accessed or is malformed. */ public static void readFileEntriesWithException2(IProject p, MindLibOrProject mp) throws CoreException, IOException { EList<MindPathEntry> list = readFileEntriesWithException(p, mp); if (mp instanceof MindLibrary) { filterMPEForLib(list); } mp.getMindpathentries().addAll(list); }
/* * Reads the classpath file entries of this project's .classpath file. * This includes the output entry. * As a side effect, unknown elements are stored in the given map (if not null) * Throws exceptions if the file cannot be accessed or is malformed. */ public static EList<MindPathEntry> readFileEntriesWithException(IProject p, MindLibOrProject mp) throws CoreException, IOException { File file = mp.eClass() == MindidePackage.Literals.MIND_LIBRARY ? getMindLibFile(p) : getMindPathFile(p); if (!file.exists()) { return setDefaultMindpath(p); } byte[] bytes; try { bytes = UtilIO.getFileByteContent(file); } catch (IOException e) { if (!file.exists()) { return setDefaultMindpath(p); } throw e; } // if (hasUTF8BOM(bytes)) { // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=240034 // int length = bytes.length-IContentDescription.BOM_UTF_8.length; // System.arraycopy(bytes, IContentDescription.BOM_UTF_8.length, bytes = new byte[length], 0, // length); // } String xmlMindpath; try { xmlMindpath = new String(bytes, UTF_8); // .mindpath always encoded with UTF-8 } catch (UnsupportedEncodingException e) { MindIdeCore.log( e, "Could not read " + MINDPATH_FILENAME + " with UTF-8 encoding"); // $NON-NLS-1$ // fallback to default xmlMindpath = new String(bytes); } return decodeMindpath(xmlMindpath); }