package Visual_DVM_2021.Passes.All; import Common.Utils.CommonUtils; import Common_old.Current; import _VisualDVM.Global; import Common_old.Utils.Utils; import GlobalData.User.User; import GlobalData.User.UserState; import Visual_DVM_2021.Passes.ProcessPass; import org.apache.commons.io.FileUtils; import java.io.File; import java.nio.file.Paths; public class LocalInitaliseUser extends ProcessPass { @Override protected boolean canStart(Object... args) throws Exception { target = Current.getUser(); return true; } @Override protected void body() throws Exception { File workspace = Paths.get(CommonUtils.Home, "User").toFile(); target.workspace = workspace.getAbsolutePath(); Utils.CheckAndCleanDirectory(workspace); FileUtils.forceMkdir(target.getLocalProjectsDir()); FileUtils.forceMkdir(target.getLocalModulesDir()); //- if (!CommonUtils.isWindows) { 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", "cd " + CommonUtils.DQuotes(target.getLocalModulesDir()), "g++ starter -o starter", "chmod 0777 starter" )); PerformScript(String.join("\n", "cd " + CommonUtils.DQuotes(target.getLocalModulesDir()), "g++ launcher.cpp -o launcher", "chmod 0777 launcher" )); } //- target.state = UserState.ready_to_work; Global.db.Update(target); } }