class BackendUtils {

    public static RepositoryFileReference getRepositoryFileReference(Path rootPath, Path path, DirectoryId directoryId) {
        final Path relativePath = rootPath.relativize(path);
        Path parent = relativePath.getParent();
        if (parent == null) {
            return new RepositoryFileReference(directoryId, path.getFileName().toString());
        } else {
            return new RepositoryFileReference(directoryId, parent, path.getFileName().toString());
        }
    }

}