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:
+3
-1
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user