Reputation: 61
I would like to know something about directory creation in C.
I know in unix based systems, you can create a directory with this function:
mkdir (const char* directory_name,mode_t mode);
but, in windows, mkdir function, only accept one argument, the name of the directory. you cannot specify mode bits for access permissions.
in windows the function for creating the directory is:
_mkdir (const char* directory_name);
so, a portable way to creating a directory is like:
#ifdef WIN32
_mkdir (directory_name);
#else
mkdir (directory_name,mode);
#endif
my question is, is there a way to specify permissions like mkdir in unix, but in windows?
Upvotes: 0
Views: 1086
Reputation: 70911
On windows there also is the chmod()
analogon _chmod()
: http://msdn.microsoft.com/en-us/library/1z319a54%28v=vs.100%29.aspx
Upvotes: 0
Reputation: 64068
You can use CreateDirectory
and supply the appropriate SECURITY_ATTRIBUTES
(the linked example uses the security descriptor and attributes for a registry key, but fundamentally this is no different than for a file).
Upvotes: 2