Files
VisualSapfor/src/_VisualDVM/Passes/All/LocalInitaliseUser.java

54 lines
2.0 KiB
Java
Raw Normal View History

2024-10-14 12:14:01 +03:00
package _VisualDVM.Passes.All;
import Common.MainModule_;
2024-10-11 00:00:30 +03:00
import Common.Utils.Utils_;
2024-10-12 00:17:51 +03:00
import _VisualDVM.Global;
2024-10-09 22:21:57 +03:00
import _VisualDVM.GlobalData.User.User;
import _VisualDVM.GlobalData.User.UserState;
2024-10-14 12:14:01 +03:00
import _VisualDVM.Passes.ProcessPass;
2024-10-14 15:19:13 +03:00
import _VisualDVM.Utils;
2023-09-17 22:13:42 +03:00
import org.apache.commons.io.FileUtils;
import java.io.File;
public class LocalInitaliseUser extends ProcessPass<User> {
@Override
protected boolean canStart(Object... args) throws Exception {
target = MainModule_.instance.getDb().getTable(User.class).getUI().getCurrent();
2023-09-17 22:13:42 +03:00
return true;
}
@Override
protected void body() throws Exception {
2024-10-11 00:00:30 +03:00
File workspace = new File(Utils_.getHomeDirectory(), "User");
2023-09-17 22:13:42 +03:00
target.workspace = workspace.getAbsolutePath();
2024-10-14 12:54:52 +03:00
Utils_.CheckAndCleanDirectory(workspace);
2023-09-17 22:13:42 +03:00
FileUtils.forceMkdir(target.getLocalProjectsDir());
FileUtils.forceMkdir(target.getLocalModulesDir());
//-
2024-10-11 00:00:30 +03:00
if (!Utils_.isWindows()) {
2023-09-17 22:13:42 +03:00
File headerCode = target.getHeaderCodeFile();
//-
File starterCode = target.getStarterCodeFile();
//-
File launcherCode = target.getLauncherCodeFile();
//-
Utils.CreateResourceFile(headerCode);
Utils.CreateResourceFile(starterCode);
Utils.CreateResourceFile(launcherCode);
//-
PerformScript(
String.join("\n",
2024-10-11 00:00:30 +03:00
"cd " + Utils_.DQuotes(target.getLocalModulesDir()),
"g++ starter -o starter",
"chmod 0777 starter"
2023-09-17 22:13:42 +03:00
));
PerformScript(String.join("\n",
2024-10-11 00:00:30 +03:00
"cd " + Utils_.DQuotes(target.getLocalModulesDir()),
"g++ launcher.cpp -o launcher",
"chmod 0777 launcher"
2023-09-17 22:13:42 +03:00
));
}
//-
target.state = UserState.ready_to_work;
2024-10-12 00:17:51 +03:00
Global.mainModule.getDb().Update(target);
2023-09-17 22:13:42 +03:00
}
}