First of all excuse me for my english. This is my first question here. I have read a lot of solutions to both common and uncommon problems on stackoverflow and IMO stackoverflow's community is the most trustful in the branch.
Currently I am developing an iOS application and recently I've encountered a problem and after some research I didn't find solution. When I am using fopen
to open existing file I am getting the following error:
open: Permission denied
The following is the code snipped which causes the error:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
NSString *cachePath = [paths objectAtIndex:0];
BOOL isDir = NO;
NSError *error;
if (! [[NSFileManager defaultManager] fileExistsAtPath:cachePath
isDirectory:&isDir] && isDir == NO) {
[[NSFileManager defaultManager] createDirectoryAtPath:cachePath
withIntermediateDirectories:NO
attributes:nil
error:&error];
}
NSString* filePath = [cachePath stringByAppendingPathComponent:
[NSString stringWithFormat:@"tmpmem%i.bin", count++]];
const char *cPath = [filePath cStringUsingEncoding:NSISOLatin1StringEncoding];
int file = open(cPath, O_RDWR | O_CREAT);
if (file == -1)
{
perror("open");
return NULL;
}
I am looking forward for your help. Thank you in advance.
Regards, B. Dimitrov