Saturday, November 30, 2013

ipad file read and write permissions problem

I use cocos2d-x development project on ipad, using c + + and object-c bound form development
Procedures needed to update the data via the network.
In the simulator environment, create folders and files can be executed properly.
But in the real machine environment, read the file properly, but can not create a folder with the file tried objectc way c + + way, are not able to create. Suspected to be a permissions problem, solve this problem friends want to help solve it, thank you. Online.
Reply:
Look where you create folders and files. document folder permissions you have any disposal. It seems there is a two directories you are arbitrary disposal. But these directories are in your app below. Something that you have no permission to the directory.
Reply:
This programming language does not matter what you look ios allows you to create directories on it, so the system design. Unless you jailbreak it unimpeded up.
Reply:
your own directory under
app
document
library
tmp
Reply:
Proven folders can be created, but can not write to the file, write the location specified in the documents under the directory app, the simulator can be, not a real machine. Tried the following two kinds of ways:
BOOL bRet = [writer writeToFile: [NSString stringWithUTF8String: szFileName] atomically: YES];
/ / BRet to FALSE not successfully written to the file

FILE * pFile = fopen (szFileName, "w");
/ / PFile NULL is successfully written to the file

:/ var/mobile/Applications/8205B9DD-A503-4B75-8792-AD760753B4E1/Documents/Data/Pid00001/0.jpg
szFileName the valueA confirmed folder does exist, can successfully write to a file on the simulator, but the real machine can not.
Reply:
Try the temp path :/ private/var/mobile/Applications/8205B9DD-A503-4B75-8792-AD760753B4E1/tmp/Data/Pid00001/0.jpg
Still can not create file
Reply:
How to put the stickers out of your szfilename
Reply:
szFileName is my own group, the simulator can be used in combination follows the path function:
char * getFullPathName (char * szSubPath, char * szOutBuff)
{
NSString * path = [NSTemporaryDirectory () stringByAppendingPathComponent:
[[[NSString alloc] initWithUTF8String: szSubPath] autorelease]];
NSUInteger len = [path length];
memcpy (szOutBuff, [path UTF8String], strlen ([path UTF8String]));
szOutBuff [len] = '\ 0';
return szOutBuff;
}
If
char szFileName [MAX_PATH];
getFullPathName ("Data/Pid00001/0.jpg", szFileName);
In memory of the print result:
/ Private/var/mobile/Applications/8205B9DD-A503-4B75-8792-AD760753B4E1/tmp/Data/Pid00001/0.jpg

Reply:
Check :/ var/mobile/Applications/8205B9DD-A503-4B75-8792-AD760753B4E1/Documents / Data/Pid00001 / 0.jpg
Are there standard red file folder write permission, or to / Data/Pid00001/0.jpg are spelled _Data_Pid00001_0.jpg, write directly to the root directory of DOC, when the path with the file name.


Reply:
Recommended the establishment of a separate test project to test the read and write files.
Reply:
/ Private/var/mobile/Applications/8205B9DD-A503-4B75-8792-AD760753B4E1/tmp/Data/Pid00001/0.jpg, a path that you get this process is too complicated, in addition to this path exists?
Reply:
/ / Gets the root directory
NSString * homeDirectory = NSHomeDirectory ();
/ / Get the address of
tmp directoryNSString * tmpDirectory = [homeDirectory stringByAppendingPathComponent: @ "tmp"];


ios developed super group, between masters and masters to those indicated from CSDN: 43146334
Reply:
Found the problem, the next documents can be written to the file, but the file created folder does not write their own file permissions.
Also found under documents path although you can write files, but can not be deleted.
Also can not find how to build a kind of permission to read, write, delete files folder
Try tomorrow with tmp folder can delete files
Reply:
reference to the second floor of the reply:
This programming language does not matter what you look ios allows you to create directories on it, so the system design. Unless you jailbreak it unimpeded up.

The key is not found this. . . Otherwise, do not ask

No comments:

Post a Comment