/**
   * Copy the required binaries and libraries to the data folder
   *
   * @return
   */
  private boolean copyBinaries() {
    try {
      String files[] = {
        "autooptimiser",
        "pto_gen",
        "cpfind",
        "multiblend",
        "enfuse",
        "nona",
        "pano_modify",
        "ptclean",
        "tiffinfo",
        "align_image_stack",
        "pto_var",
        "libexiv2.so",
        "libglib-2.0.so",
        "libgmodule-2.0.so",
        "libgobject-2.0.so",
        "libgthread-2.0.so",
        "libjpeg.so",
        "libpano13.so",
        "libtiff.so",
        "libtiffdecoder.so",
        "libvigraimpex.so"
      };

      final AssetManager am = mContext.getAssets();

      for (String file : files) {
        InputStream is = am.open("picsphere/" + file);

        // Create the output file
        File dir = mContext.getFilesDir();
        File outFile = new File(dir, file);

        if (outFile.exists()) outFile.delete();

        OutputStream os = new FileOutputStream(outFile);

        // Copy the file
        byte[] buffer = new byte[1024];
        int read;
        while ((read = is.read(buffer)) != -1) {
          os.write(buffer, 0, read);
        }

        if (!outFile.getName().endsWith(".so") && !outFile.setExecutable(true)) {
          return false;
        }

        os.flush();
        os.close();
        is.close();
      }
    } catch (Exception e) {
      Log.e(TAG, "Error copying libraries and binaries", e);
      return false;
    }
    return true;
  }