09-01-2012 01:36 PM
It seams that applications perform differently when debugged - run on the device (PlayBook tablet) and when they are signed.
I have included some files in my assets folder
and at some point in my code I have:
std::string strFile = "app/native/assets/Home/myfile.dat";
FILE* pFile = fopen( strFile.c_str(), "r+b" );
if ( pFile )
// do something
the above code works ok when running an unsigned application whether its a debug or release version. The moment I sign my .bar and upload it on the device the fopen fails.
if (stat(strFile.c_str(), &sts) != 0 )
fprintf(...., "%d, %s\n", errno, strerror(errno) );
To check the reason for failing I get the error code: 3 which is: No such process
On the other hand if I have:
FILE* pFile = fopen( strFile.c_str(), "rb" );
then the code runs ok and pFile != NULL
As I said It seams that applications perform differently when debugged - run on the device (PlayBook tablet) and when they are signed.
Solved! Go to Solution.
09-01-2012 01:44 PM
10-24-2012 08:32 PM
10-24-2012 08:39 PM
10-24-2012 08:58 PM - edited 10-24-2012 09:00 PM
I don't think it should be a new question. It's directly related and compliments the information you provided. I came to this thread with the exact same fopen() issues in the signed BAR as the OP. Anyway, here's what I found for others who come to this thread:
The $HOME environment variable contains the full path to your app's /data directory. You can get it and contruct a path like so:
char* homeData = getenv("HOME");
sprintf(filePathBuf, "%s/my_file.mf", homeData);
remove(filePathBuf); // (1) Delete existing file if present.
FILE* pStream = fopen(filePathBuf, "a+b"); // (2) Create new file.
I can confirm both (1) and (2) now work for me in a signed BAR.