Debuggin the fomod feature & adding the framework for basic error handling in the fomod code.

Still need to do proper error handling but at least we can easly catch the errors.
This commit is contained in:
Marc
2022-09-26 08:56:05 +02:00
parent f93e93943d
commit 825a232d5a
6 changed files with 333 additions and 73 deletions
+3 -1
View File
@@ -14,6 +14,7 @@ u_int32_t countSetBits(u_int32_t n) {
return (n & 1) + countSetBits(n >> 1);
}
//TODO: add interruption support
//simplest way to copy a file in c(linux)
int copy(const char * path, const char * dest, u_int32_t flags) {
int flagCount = countSetBits(flags);
@@ -23,7 +24,6 @@ int copy(const char * path, const char * dest, u_int32_t flags) {
}
//flags + cp + path + dest
const char * args[flagCount + 4];
memset(args, 0, (flagCount + 4) * sizeof(char *));
args[0] = "/bin/cp";
args[1] = path;
args[2] = dest;
@@ -42,6 +42,8 @@ int copy(const char * path, const char * dest, u_int32_t flags) {
argIndex += 1;
}
args[argIndex] = NULL;
int pid = fork();
if(pid == 0) {