Hi, I've created a a folder and after I open a file inside of that folder a write on it. It happens that after that I try to open the file but I have no permissions thus I have to change it manually.
/* str1 has tha name of the folder */
/* str the bytes I want to write in the file inside the folder*/
...
mkdir(str1,0777);
if (filefd < 0) {
strncpy(auxstr, str, MAX_MSG + 1);
strcat(str1,"\\");
strcat(str1, auxstr);
filefd = open (str1, O_RDWR | O_CREAT | O_TRUNC);
nbytes -= (strlen(str) + 1);
memcpy(auxstr, &str[strlen(str)+1], nbytes);
memcpy(str, auxstr, nbytes);
}
/*write to the file */
if ((nwritten = write(filefd, str, nbytes)) != nbytes) {
printf ("can't write on file\n");
break;
}
What should I change in order to have permissions to open the created file?
Thanks a lot,