| | |
Dir creating, permissions setting issue!
![]() |
•
•
Join Date: Sep 2007
Posts: 38
Reputation:
Solved Threads: 0
Hello, I need to create some dirs (one for each user), taking the dir name from a given string.
I managed to do this with the following code:
My problem is these dirs are created with no permissions at all, I've got to set them manually doing "chmod 777 name", is there a function out there to create dirs with permissions already setted? I need to use them later from inside my application and I want the users to be able to modify them from the OS (ie adding files inside).
I use Debian, in XP no problems!
I managed to do this with the following code:
C Syntax (Toggle Plain Text)
DIR *dir_ptr; char *target_dir; target_dir = malloc(32*sizeof(char)); for(all users) { /* Set username for current user */ target_dir[0] = '\0'; strcat(target_dir, "./Environment"); strcat(target_dir, "/"); strcat(target_dir, username); strcat(target_dir, "/"); /* check for DIR existence, if not, create */ if((dir_ptr = opendir(target_dir)) == NULL) mkdir(target_dir); }
My problem is these dirs are created with no permissions at all, I've got to set them manually doing "chmod 777 name", is there a function out there to create dirs with permissions already setted? I need to use them later from inside my application and I want the users to be able to modify them from the OS (ie adding files inside).
I use Debian, in XP no problems!
Apparently, mkdir() takes 2 parameters.
http://www.rocketaware.com/man/man2/mkdir.2.htm
One wonders whether
- you read the manual before calling it
- included the appropriate header file which would have warned you about too few parameters
- mis-took early success on other platforms as a sign of bug-free code.
http://www.rocketaware.com/man/man2/mkdir.2.htm
One wonders whether
- you read the manual before calling it
- included the appropriate header file which would have warned you about too few parameters
- mis-took early success on other platforms as a sign of bug-free code.
![]() |
Other Threads in the C Forum
- Previous Thread: Integration in C
- Next Thread: Problem Converting String to Float - Using ATOF
| Thread Tools | Search this Thread |
* adobe api array asterisks binarysearch calculate changingto char character cm copyanyfile copyimagefile copypdffile creafecopyofanytypeoffileinc createcopyoffile createprocess() csyntax database directory feet fgets file floatingpointvalidation forloop frequency function givemetehcodez global grade gtkgcurlcompiling gtkwinlinux hacking highest histogram homework i/o infiniteloop input interest intmain() iso kernel keyboard kilometer km linked linkedlist linux looping loopinsideloop. lowest meter microsoft mqqueue mysql number oddnumber odf open openwebfoundation owf pdf performance posix power probleminc process programming pyramidusingturboccodes radix read recv recvblocked repetition research reversing scheduling segmentationfault send sequential single socket socketprogramming stack standard string suggestions systemcall threads turboc unix urboc user variable wab whythiscodecausesegmentationfault win32api windows.h windowsapi






