Example #1
0
 // process MML
 public void processMML(File f, String pmodel, String mml) throws Exception {
   String id = f.getPath();
   if (pmodel != null) id = id + "#" + pmodel;
   mml = mml.trim() + "\n";
   Integer hmml = new Integer(mml.hashCode());
   String oid = mmlIDs.get(hmml);
   if (oid != null) {
     System.out.println("Ignoring " + id + " matches " + oid);
     return;
   }
   mmlIDs.put(hmml, id);
   int inx = 1000 + ++ninxs;
   String fname = "" + inx + ".mod";
   inxwrt.println("" + fname + "\t" + hmml + "\t" + id);
   File fout = new File(destDir, fname);
   UtilIO.writeText(fout, mml);
 }
  /*
   * 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);
  }
Example #3
0
 // harvest mod file
 public void harvestMod(File f) throws Exception {
   String mml = UtilIO.readText(f);
   processMML(f, null, mml);
 }
  public void close() throws IOException {

    for (final OutputStream ostream : ostream_) {
      UtilIO.closeProperly(ostream);
    }
  }