@@ -79,6 +79,36 @@ public String getFormatted(File file, String rawUnix) {
79
79
}
80
80
}
81
81
82
+ private static class CleanProviderFolder implements CleanProvider {
83
+ private final Path rootDir ;
84
+ private final Path cleanDir ;
85
+ private final Charset encoding ;
86
+
87
+ CleanProviderFolder (Path rootDir , Path cleanDir , String encoding ) {
88
+ this .rootDir = rootDir ;
89
+ this .cleanDir = cleanDir ;
90
+ this .encoding = Charset .forName (encoding );
91
+ }
92
+
93
+ @ Override
94
+ public Path getRootDir () {
95
+ return rootDir ;
96
+ }
97
+
98
+ @ Override
99
+ public Charset getEncoding () {
100
+ return encoding ;
101
+ }
102
+
103
+ @ Override
104
+ public String getFormatted (File file , String rawUnix ) {
105
+ Path relative = rootDir .relativize (file .toPath ());
106
+ Path clean = cleanDir .resolve (rootDir .relativize (file .toPath ()));
107
+ byte [] content = Errors .rethrow ().get (() -> Files .readAllBytes (clean ));
108
+ return new String (content , encoding );
109
+ }
110
+ }
111
+
82
112
public static class Builder {
83
113
private Builder () {}
84
114
@@ -97,6 +127,11 @@ public Builder formatter(Formatter formatter) {
97
127
return this ;
98
128
}
99
129
130
+ public Builder formatterFolder (Path rootDir , Path cleanDir , String encoding ) {
131
+ this .formatter = new CleanProviderFolder (rootDir , cleanDir , encoding );
132
+ return this ;
133
+ }
134
+
100
135
public Builder problemFiles (List <File > problemFiles ) {
101
136
this .problemFiles = Objects .requireNonNull (problemFiles );
102
137
Preconditions .checkArgument (!problemFiles .isEmpty (), "cannot be empty" );
0 commit comments