Files
VisualSapfor/src/SapforTestingSystem/Json/SapforVersion_json.java

67 lines
2.5 KiB
Java
Raw Normal View History

2023-09-21 20:55:14 +03:00
package SapforTestingSystem.Json;
import Common.Constants;
2023-10-30 22:37:03 +03:00
import Common.Global;
import Common.Utils.Utils;
import ProjectData.Files.FileType;
2023-10-31 01:51:08 +03:00
import ProjectData.Files.ProjectFile;
2023-09-17 22:13:42 +03:00
import com.google.gson.annotations.Expose;
2023-10-30 22:37:03 +03:00
import java.io.File;
import java.io.Serializable;
2023-10-30 22:37:03 +03:00
import java.nio.file.Paths;
import java.util.Vector;
public class SapforVersion_json implements Serializable {
2023-09-17 22:13:42 +03:00
@Expose
public String version = "";
@Expose
public String description = "";
2023-11-03 02:00:17 +03:00
public boolean success = true;
//поля для отображения деревьев.
public File Home = null;
2023-10-31 01:51:08 +03:00
public Vector<ProjectFile> files = null;
//-
2023-09-17 22:13:42 +03:00
public SapforVersion_json(String version_in, String description_in) {
version = version_in;
description = description_in;
}
2023-10-29 01:03:37 +03:00
public SapforVersion_json(String root_in, String version_in, String description_in) {
version = version_in.substring(root_in.length() + 1);
description = description_in;
}
2023-10-30 22:37:03 +03:00
@Override
public String toString() {
return Home.getName() + " : " + Utils.Brackets(description);
2023-10-30 22:37:03 +03:00
}
public void init(File configurationRoot) {
2023-10-30 22:37:03 +03:00
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()) {
2023-10-31 01:51:08 +03:00
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);
}
}
2023-10-30 22:37:03 +03:00
}
2023-09-17 22:13:42 +03:00
}