I'm porting a C library to OSX which haven't given me much of a headache until now. In the next function:
int createDirectory( char *directory ){
int error;
error = mkdir(directory, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
if( error < 0 ){
if( errno != EEXIST ){
return errno;
}
}
return error;
}
No matter what directory
is, mkdir()
always fails with EPERM
(Operation not permitted). I'm not sure if the xcode executable is sandboxed or if I'm missing something, but every path I pass to the function fails.
I've tried to mkdir from the terminal and the folders are created without a problem, so I'm not sure where the problem is. This function works fine in Linux and Solaris.
Example paths:
"~/Library/Application\ Support/myApp"
"~/Desktop/myApp"
The first one is an actual example of a directory the library should create.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…