/**
   * Return an input stream for a library file with the given name. If no such file/resource exists,
   * returns null.
   */
  public static InputStream getLibraryFile(String name) {
    // allow user version in ~/.bubbles

    String pname = name.replace("/", File.separator);

    File dir0 = new File(prop_base);
    if (dir0.exists()) {
      File f3 = new File(dir0, pname);
      if (f3.exists() && f3.canRead()) {
        try {
          return new FileInputStream(f3);
        } catch (IOException e) {
        }
      }
    }

    BoardProperties sp = getProperties("System");
    String dir = sp.getProperty(BOARD_PROP_INSTALL_DIR);

    URL url = BoardProperties.class.getClassLoader().getResource(BOARD_RESOURCE_CHECK);

    // use jar version if available
    if (url != null) {
      String nm = "lib/" + name;
      InputStream ins = BoardProperties.class.getClassLoader().getResourceAsStream(nm);
      if (ins != null) return ins;
      dir = sp.getProperty(BOARD_PROP_JAR_DIR);
    }

    // use whats in the lib directory
    File f1 = new File(dir);
    File f2 = new File(f1, "lib");
    File f3 = new File(f2, pname);

    try {
      return new FileInputStream(f3);
    } catch (IOException e) {
    }

    return null;
  }