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-07 00:58:29 +03:00
|
|
|
import Common_old.Current;
|
|
|
|
|
import _VisualDVM.Global;
|
|
|
|
|
import Common_old.Utils.Utils;
|
2023-09-17 22:13:42 +03:00
|
|
|
import GlobalData.User.User;
|
|
|
|
|
import GlobalData.User.UserState;
|
2023-11-19 02:12:44 +03:00
|
|
|
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-07 22:04:09 +03:00
|
|
|
File workspace = Paths.get(CommonUtils.Home, "User").toFile();
|
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-07 22:04:09 +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()),
|
2024-01-08 20:37:16 +03:00
|
|
|
"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()),
|
2024-01-08 20:37:16 +03:00
|
|
|
"g++ launcher.cpp -o launcher",
|
|
|
|
|
"chmod 0777 launcher"
|
2023-09-17 22:13:42 +03:00
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
//-
|
|
|
|
|
target.state = UserState.ready_to_work;
|
|
|
|
|
Global.db.Update(target);
|
|
|
|
|
}
|
|
|
|
|
}
|