методы копирования
This commit is contained in:
8
.idea/workspace.xml
generated
8
.idea/workspace.xml
generated
@@ -6,7 +6,13 @@
|
||||
</artifacts-to-build>
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="e42177c3-2328-4b27-8a01-35779b2beb99" name="Default Changelist" comment="" />
|
||||
<list default="true" id="e42177c3-2328-4b27-8a01-35779b2beb99" name="Default Changelist" comment="">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/TestingSystem/DVM/TestsSupervisor_2022.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/DVM/TestsSupervisor_2022.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/TestingSystem/DVM/UserConnection.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/DVM/UserConnection.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/files/Planner/CompilationTask.h" beforeDir="false" afterPath="$PROJECT_DIR$/src/files/Planner/CompilationTask.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/files/Planner/Utils.h" beforeDir="false" afterPath="$PROJECT_DIR$/src/files/Planner/Utils.h" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||
|
||||
@@ -164,9 +164,14 @@ public class TestsSupervisor_2022 {
|
||||
}
|
||||
public void DownloadResults() throws Exception {
|
||||
Utils.CheckDirectory(packageLocalWorkspace);
|
||||
RemoteFile remote_results = new RemoteFile(packageRemoteWorkspace, "results");
|
||||
RemoteFile remote_results_archive = new RemoteFile(packageRemoteWorkspace, "results.zip");
|
||||
connection.ShellCommand(
|
||||
|
||||
"zip -r "+Utils.DQuotes(remote_results_archive.full_name)+" "+Utils.DQuotes(remote_results.full_name));
|
||||
/*
|
||||
RemoteFile remote_results_archive = new RemoteFile(packageRemoteWorkspace.full_name, "results.zip");
|
||||
File results_archive = new File(packageLocalWorkspace, "results.zip");
|
||||
|
||||
if (connection.Exists()) {
|
||||
connection.getSingleFile(remote_results_archive, results_archive);
|
||||
UnzipFolderPass unzipFolderPass = new UnzipFolderPass();
|
||||
|
||||
@@ -109,14 +109,10 @@ public class UserConnection {
|
||||
//следует перенаправлять вывод в какой нибудь временный файл на сервере.
|
||||
public String ShellCommand(String command) throws Exception {
|
||||
StringBuilder result = new StringBuilder();
|
||||
// System.out.println("command=" + Utils.Brackets(command));
|
||||
pin.write((command + "\r\n").getBytes());
|
||||
ShellParser.ReadInvitation(fromServer); //первое приглашение после эхо. возможен мусор.
|
||||
result.append(ShellParser.getCommandResult(fromServer)); //возможный результат и второе приглашение.
|
||||
// System.out.println("answer=" + Utils.Brackets(result));
|
||||
//в реалиях визуалиазтора нас интересует только ПОСЛЕДНЯЯ СТРОКА ОТВЕТА.
|
||||
String[] data = result.toString().split("\n");
|
||||
// System.out.println("res="+Utils.Brackets(res));
|
||||
return (data.length > 0) ? data[data.length - 1] : result.toString();
|
||||
}
|
||||
public void getSingleFile(String src, String dst) throws Exception {
|
||||
|
||||
@@ -31,8 +31,7 @@ public:
|
||||
File makeFileFile = File(makeFilePath, this->makefile_text);
|
||||
String tests = userWorkspace + "/projects";
|
||||
String testPath = tests + "/" + test_id;
|
||||
String copyCommand = "cp -r " + String::DQuotes(testPath + "/.") + " " + String::DQuotes(workspace);
|
||||
system(copyCommand.getCharArray());
|
||||
Utils::CopyDirectory(testPath, workspace);
|
||||
}
|
||||
virtual String getLaunchScriptText() {
|
||||
String modules = userWorkspace + "/modules";
|
||||
|
||||
@@ -31,8 +31,13 @@ public:
|
||||
|
||||
//https://stackoverflow.com/questions/4568681/using-chmod-in-a-c-program
|
||||
static void Chmod(const String& path) {
|
||||
String command = "chmod 777 " + String::DQuotes(path);
|
||||
system(command.getCharArray());
|
||||
#if __cplusplus >= 201703L
|
||||
std::filesystem::permissions(path.getCharArray(), std::filesystem::perms::all);
|
||||
#else
|
||||
String command = "chmod 777 " + String::DQuotes(path);
|
||||
int i=system(command.getCharArray());
|
||||
printf("chmod 777 '%s' return code = %d\n", path.getCharArray(), i);
|
||||
#endif
|
||||
}
|
||||
|
||||
//https://stackoverflow.com/questions/230062/whats-the-best-way-to-check-if-a-file-exists-in-c
|
||||
@@ -47,9 +52,23 @@ public:
|
||||
std::this_thread::sleep_for(timespan);
|
||||
}
|
||||
static void Copy(const String& src, const String& dst) {
|
||||
String command = "cp " + String::DQuotes(src) + " " + String::DQuotes(dst);
|
||||
system(command.getCharArray());
|
||||
#if __cplusplus >= 201703L
|
||||
std::filesystem::copy(src.getCharArray(), dst.getCharArray());
|
||||
#else
|
||||
String command = "cp " + String::DQuotes(src) + " " + String::DQuotes(dst);
|
||||
int i = system(command.getCharArray());
|
||||
printf("cp '%s' return code = %d\n",src.getCharArray(), i);
|
||||
#endif
|
||||
}
|
||||
static void CopyDirectory(const String& src, const String& dst) {
|
||||
#if __cplusplus >= 201703L
|
||||
std::filesystem::copy((src+ "/.").getCharArray(), dst.getCharArray(), std::filesystem::copy_options::recursive);
|
||||
#else
|
||||
String command = "cp -r " + String::DQuotes(src + "/.") + " " + String::DQuotes(dst);
|
||||
int i = system(command.getCharArray());
|
||||
printf("cp -r '%s' return code = %d\n",src.getCharArray(),i);
|
||||
#endif
|
||||
}
|
||||
static time_t getAbsoluteTime() {
|
||||
return time(NULL);
|
||||
}
|
||||
@@ -58,8 +77,4 @@ public:
|
||||
String res(ctime(&ttime));
|
||||
return res;
|
||||
}
|
||||
static void ZipFolder(const String& src, const String& dst) {
|
||||
String command = "zip -r " + String::DQuotes(dst) + " " + String::DQuotes(src);
|
||||
system(command.getCharArray());
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user