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

54 lines
1.9 KiB
Java
Raw Normal View History

package Visual_DVM_2021.Passes.All;
2024-10-07 14:22:52 +03:00
import Common.Utils.CommonUtils;
import Common_old.Current;
import Common_old.Utils.Utils;
2023-09-17 22:13:42 +03:00
import GlobalData.User.User;
import GlobalData.User.UserState;
import Visual_DVM_2021.Passes.ProcessPass;
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 LocalInitaliseUser extends ProcessPass<User> {
@Override
protected boolean canStart(Object... args) throws Exception {
target = Current.getUser();
return true;
}
@Override
protected void body() throws Exception {
2024-10-08 22:33:49 +03:00
File workspace = new File(CommonUtils.getHomeDirectory(), "User");
2023-09-17 22:13:42 +03:00
target.workspace = workspace.getAbsolutePath();
Utils.CheckAndCleanDirectory(workspace);
FileUtils.forceMkdir(target.getLocalProjectsDir());
FileUtils.forceMkdir(target.getLocalModulesDir());
//-
2024-10-08 22:33:49 +03:00
if (!CommonUtils.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-07 14:22:52 +03:00
"cd " + CommonUtils.DQuotes(target.getLocalModulesDir()),
"g++ starter -o starter",
"chmod 0777 starter"
2023-09-17 22:13:42 +03:00
));
PerformScript(String.join("\n",
2024-10-07 14:22:52 +03:00
"cd " + CommonUtils.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;
CommonUtils.db.Update(target);
2023-09-17 22:13:42 +03:00
}
}