Beispiel #1
0
 private static boolean canWrite(URL location) {
   if (location != null && "file".equals(location.getProtocol())) { // $NON-NLS-1$
     File locationDir = new File(location.getFile());
     if (!locationDir.exists()) locationDir.mkdirs();
     if (locationDir.exists() && AdaptorUtil.canWrite(locationDir)) return true;
   }
   return false;
 }
Beispiel #2
0
  private static String computeDefaultConfigurationLocation() {
    // 1) We store the config state relative to the 'eclipse' directory if possible
    // 2) If this directory is read-only
    //    we store the state in <user.home>/.eclipse/<application-id>_<version> where <user.home>
    //    is unique for each local user, and <application-id> is the one
    //    defined in .eclipseproduct marker file. If .eclipseproduct does not
    //    exist, use "eclipse" as the application-id.

    URL installURL = computeInstallConfigurationLocation();
    if (installURL != null && "file".equals(installURL.getProtocol())) { // $NON-NLS-1$
      File installDir = new File(installURL.getFile());
      File defaultConfigDir = new File(installDir, CONFIG_DIR);
      if (!defaultConfigDir.exists()) defaultConfigDir.mkdirs();
      if (defaultConfigDir.exists() && AdaptorUtil.canWrite(defaultConfigDir))
        return defaultConfigDir.getAbsolutePath();
    }
    // We can't write in the eclipse install dir so try for some place in the user's home dir
    return computeDefaultUserAreaLocation(CONFIG_DIR);
  }
Beispiel #3
0
 /**
  * Returns a file from the configuration area that can be used by the framework
  *
  * @param filename the filename
  * @return a file from the configuration area
  */
 public static File getConfigurationFile(String filename) {
   File dir = getOSGiConfigurationDir();
   if (!dir.exists()) dir.mkdirs();
   return new File(dir, filename);
 }