Forgot to copy the chdir bit. Erm well if I pass the function folder/folder1/folder2 It creates those folders just like that, one inside another. Just need a way to test if there is ../ and chdir instead of creating
Code:
void createdirstruct(char *folder) {
char tokfolder[512];
int i;
for (i = 0; i <= strlen(folder); i++) {
if (folder[i] == '/' || folder[i] == '\0') {
strncpy(tokfolder, folder, i);
tokfolder[i] = '\0';
if(mkdir(tokfolder, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) == -1) {
printf("Restoring folder structure failed.\n");
exit (13);
}
if(chdir(tokfolder) == -1) {
printf("Directory change to %s failed\n",tokfolder);
exit (11);
}
}
}
}