public static FileBasedMatcher create()

in command.line/java/com/jetbrains/teamcity/resources/FileBasedMatcher.java [27:65]


  public static FileBasedMatcher create(final File rootFolder, final Map<File, String> localToRepo) throws IllegalArgumentException {
    // check arguments
    if (rootFolder == null || localToRepo == null) {
      throw new IllegalArgumentException(MessageFormat.format("Root or Map is null: {0}, {1}", rootFolder, localToRepo));
    }
    // create content
    try {
      final File absoluteRoot = rootFolder.getCanonicalFile().getAbsoluteFile();
      final HashMap<String, String> pathToRepoMap = new HashMap<String, String>();

      // transform into plain Strings
      for (final Map.Entry<File, String> entry : localToRepo.entrySet()) {

        final File absoluteEntryFile = entry.getKey().getCanonicalFile();
        final String repoPrefix = Util.toPortableString(entry.getValue());

        if (absoluteRoot.equals(absoluteEntryFile)) {
          // provide "."
          pathToRepoMap.put(CURRENT_DIR, repoPrefix);
        } else {
          final String relativePath = FileUtil.getRelativePath(absoluteRoot, absoluteEntryFile);
          pathToRepoMap.put(relativePath, repoPrefix);
        }
      }
      // persist
      final StringBuffer buffer = new StringBuffer();
      for (Map.Entry<String, String> entry : pathToRepoMap.entrySet()) {
        buffer.append(entry.getKey()).append(FIELD_DEVIDER).append(entry.getValue()).append("\n");
      }
      final File adminFile = new File(rootFolder, TCWorkspace.TCC_ADMIN_FILE);
      FileUtil.writeFile(adminFile, buffer.toString().trim());

      return new FileBasedMatcher(adminFile);

    } catch (IOException e) {
      throw new IllegalArgumentException(e);

    }
  }