fixed and improved

This commit is contained in:
2023-12-05 16:03:42 +03:00
parent 0bd2d3fe36
commit 5e229fcb68
5 changed files with 34 additions and 20 deletions

View File

@@ -31,19 +31,23 @@ public:
//https://stackoverflow.com/questions/4568681/using-chmod-in-a-c-program
static void Chmod(const String& path) {
#if __cplusplus >= 201703L
#if __cplusplus >= 201703L
std::filesystem::permissions(path.getCharArray(), std::filesystem::perms::all);
#else
#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
#endif
}
//https://stackoverflow.com/questions/230062/whats-the-best-way-to-check-if-a-file-exists-in-c
static bool Exists(const String& path) {
#if __cplusplus >= 201703L
return std::filesystem::exists(path.getCharArray());
#else
struct stat buffer;
return (stat(path.getCharArray(), &buffer) == 0);
#endif
}
//in seconds
@@ -52,22 +56,22 @@ public:
std::this_thread::sleep_for(timespan);
}
static void Copy(const String& src, const String& dst) {
#if __cplusplus >= 201703L
#if __cplusplus >= 201703L
std::filesystem::copy(src.getCharArray(), dst.getCharArray());
#else
#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
#endif
}
static void CopyDirectory(const String& src, const String& dst) {
#if __cplusplus >= 201703L
#if __cplusplus >= 201703L
std::filesystem::copy((src+ "/.").getCharArray(), dst.getCharArray(), std::filesystem::copy_options::recursive);
#else
#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
#endif
}
static time_t getAbsoluteTime() {
return time(NULL);