Package org.sugarj.common.path

Examples of org.sugarj.common.path.Path


  public static Path newTempFile(String suffix) throws IOException {
    File f =
        File.createTempFile(
            "sugarj",
            suffix == null || suffix.isEmpty() ? suffix : "." + suffix);
    final Path p = new AbsolutePath(f.getAbsolutePath());
   
    return p;
  }
View Full Code Here


  public static Path newTempDir() throws IOException {
    final File f = File.createTempFile("SugarJ", "");
    // need to delete the file, but want to reuse the filename
    f.delete();
    f.mkdir();
    final Path p = new AbsolutePath(f.getAbsolutePath());
   
    return p;
  }
View Full Code Here

   
    return p;
  }

  public static void prependToFile(Path file, String head) throws IOException {
    Path tmp = newTempFile("");
    file.getFile().renameTo(tmp.getFile());

    FileInputStream in = new FileInputStream(tmp.getFile());
    FileOutputStream out = new FileOutputStream(file.getFile());

    out.write(head.getBytes());

    int len;
View Full Code Here

   * @param hash
   * @return
   * @throws IOException
   */
  public static Path createFile(Path dir, int hash) throws IOException {
    Path p = new RelativePath(dir, hashFileName("sugarj", hash));
    createFile(p);
    return p;
  }
View Full Code Here

   * @param hash
   * @return
   * @throws IOException
   */
  public static Path createDir(Path dir, int hash) throws IOException {
    Path p = new RelativePath(dir, hashFileName("SugarJ", hash));
    createDir(p);
    return p;
  }
View Full Code Here

    return null;
  }
 
  public static Path tryCopyFile(Path from, Path to, Path file) throws IOException {
    RelativePath p = getRelativePath(from, file);
    Path target = file;
    if (p != null) {
      target = new RelativePath(to, p.getRelativePath());
      copyFile(p, target);
    }
    return target;
View Full Code Here

   
    for (Path grammarFile : baseLang.getPackagedGrammars()) {
      Map<String, Integer> map = new HashMap<String, Integer>();
      map.put(grammarFile.getAbsolutePath(), FileCommands.fileHash(grammarFile));
      ModuleKey key = new ModuleKey(map, "");
      Path permissiveGrammar = lookupGrammarInCache(sdfCache, key);
      if (permissiveGrammar == null) {
        permissiveGrammar = FileCommands.newTempFile("def");
        makePermissive(new AbsolutePath(grammarFile.getAbsolutePath()), permissiveGrammar);
        permissiveGrammar = cacheParseTable(sdfCache, key, permissiveGrammar, environment);
      }
     
      cmd.add("-Idef");
      cmd.add(FileCommands.nativePath(permissiveGrammar.getAbsolutePath()));
    }
   
    cmd.add("-I");
    cmd.add(FileCommands.nativePath(baseLang.getPluginDirectory().getAbsolutePath()));
    cmd.add("-I");
View Full Code Here

    if (!tbl.getFile().exists())
      throw new RuntimeException("execution of sdf2table failed");
  }

  private static void normalizeTable(Path def, String module) throws IOException {
    Path tbl = FileCommands.newTempFile("tbl");
    sdf2Table(def, tbl, module, true);
    FileCommands.deleteTempFiles(tbl);
  }
View Full Code Here

    sdf2Table(def, tbl, module, true);
    FileCommands.deleteTempFiles(tbl);
  }
 
  public static void check(Path sdf, String module, Collection<Path> paths, ModuleKeyCache<Path> sdfCache, Environment environment, AbstractBaseLanguage baseLang) throws IOException {
    Path def = FileCommands.newTempFile("def");
    packSdf(sdf, def, paths, sdfCache, environment, baseLang);
    normalizeTable(def, module);
    FileCommands.deleteTempFiles(def);
  }
View Full Code Here

                              AbstractBaseLanguage baseLang) throws IOException,
                                                          InvalidParseTableException,
                                                          TokenExpectedException,
                                                          SGLRException {
    ModuleKey key = getModuleKeyForGrammar(sdf, module, dependentFiles, sdfParser);
    Path tbl = lookupGrammarInCache(sdfCache, key);
    if (tbl == null) {
      tbl = generateParseTable(key, sdf, module, environment.getIncludePath(), sdfCache, environment, baseLang);
      tbl = cacheParseTable(sdfCache, key, tbl, environment);
    }
   
View Full Code Here

TOP

Related Classes of org.sugarj.common.path.Path

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.