Files
VisualSapfor/src/SapforTestingSystem/Json/SapforVersion_json.java
2023-11-03 02:00:17 +03:00

67 lines
2.5 KiB
Java

package SapforTestingSystem.Json;
import Common.Constants;
import Common.Global;
import Common.Utils.Utils;
import ProjectData.Files.FileType;
import ProjectData.Files.ProjectFile;
import com.google.gson.annotations.Expose;
import java.io.File;
import java.io.Serializable;
import java.nio.file.Paths;
import java.util.Vector;
public class SapforVersion_json implements Serializable {
@Expose
public String version = "";
@Expose
public String description = "";
public boolean success = true;
//поля для отображения деревьев.
public File Home = null;
public Vector<ProjectFile> files = null;
//-
public SapforVersion_json(String version_in, String description_in) {
version = version_in;
description = description_in;
}
public SapforVersion_json(String root_in, String version_in, String description_in) {
version = version_in.substring(root_in.length() + 1);
description = description_in;
}
@Override
public String toString() {
return Home.getName() + " : " + Utils.Brackets(description);
}
public void init(File configurationRoot) {
String relativePath = Global.isWindows ? Utils.toW(version) : version;
Home = Paths.get(configurationRoot.getAbsolutePath(), relativePath).toFile();
files = new Vector<>();
//--
File[] files_ = Home.listFiles();
if (files_ != null) {
for (File file : files_) {
if (file.isFile()) {
ProjectFile projectFile = new ProjectFile(file);
if (!projectFile.fileType.equals(FileType.forbidden)) {
files.add(projectFile);
}
}
}
}
//теперь файлы вывода.
Vector<File> out_files = new Vector<>();
out_files.add(Paths.get(Home.getAbsolutePath(), Constants.data, Constants.parse_out_file).toFile());
out_files.add(Paths.get(Home.getAbsolutePath(), Constants.data, Constants.parse_err_file).toFile());
out_files.add(Paths.get(Home.getAbsolutePath(), Constants.data, Constants.out_file).toFile());
out_files.add(Paths.get(Home.getAbsolutePath(), Constants.data, Constants.err_file).toFile());
//--
for (File file : out_files) {
if (file.exists()) {
// System.out.println(file.getAbsolutePath());
ProjectFile projectFile = new ProjectFile(file);
files.add(projectFile);
}
}
}
}