2023-11-19 02:12:44 +03:00
|
|
|
package Visual_DVM_2021.Passes.All;
|
2024-10-07 14:22:52 +03:00
|
|
|
import Common.Utils.CommonUtils;
|
2024-10-09 22:21:57 +03:00
|
|
|
import _VisualDVM.ProjectData.Files.DBProjectFile;
|
2023-11-19 02:12:44 +03:00
|
|
|
import Visual_DVM_2021.Passes.Transformation;
|
2023-09-17 22:13:42 +03:00
|
|
|
import org.apache.commons.io.FileUtils;
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.nio.file.Paths;
|
|
|
|
|
public class EraseBadSymbols extends Transformation {
|
|
|
|
|
@Override
|
|
|
|
|
protected void body() throws Exception {
|
|
|
|
|
for (DBProjectFile file : target.db.files.Data.values()) {
|
|
|
|
|
String file_text = FileUtils.readFileToString(file.file);
|
|
|
|
|
StringBuilder res_text = new StringBuilder();
|
|
|
|
|
for (char c : file_text.toCharArray()) {
|
2024-10-07 14:22:52 +03:00
|
|
|
if (CommonUtils.isEnglishLetter(c) || Character.isDigit(c) || CommonUtils.isSign(c)) {
|
2023-09-17 22:13:42 +03:00
|
|
|
res_text.append(c);
|
2024-10-07 14:22:52 +03:00
|
|
|
} else if (CommonUtils.isRussianLetter(c))
|
|
|
|
|
res_text.append(CommonUtils.Translit(c));
|
2023-09-17 22:13:42 +03:00
|
|
|
else res_text.append(' ');
|
|
|
|
|
}
|
2024-10-08 22:33:49 +03:00
|
|
|
File dst = Paths.get(target.last_version.Home.getAbsolutePath(), CommonUtils.isWindows() ? file.name : file.name.replace('\\', '/')).toFile();
|
2023-09-17 22:13:42 +03:00
|
|
|
FileUtils.write(dst, res_text.toString());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|