Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Contributor
Posts: 10
Registered: ‎11-14-2011
My Device: Blackberry Playbook
My Carrier: T-Mobile
Accepted Solution

File Problem with app folder

Hi everyone, just wondering what could be causing my problem. When I build and launch in debug my application works fine loading a ROM from its own cluster of files. When I compile as release it suddenly seems to not be able to load the file into memory. My built in logging tells me that the file can be opened but simply does not read into memory as the following code

strcpy(filenamechars, filePath.c_str());
	std::ifstream file;
	file.open(filenamechars, std::ios::out | std::ios::binary);
	if((file.fail() != 0))
		{
			mainLog.message = "FAILURE AHAHAHAHAHAAHHAHA GOTCHA (TEH ROM WONT REAAD!!!)\n";
			mainLog.writeMessage();
		}
	file.seekg(0, ios::beg);
	int begin = file.tellg();
	file.seekg(0, ios::end);
	int end = file.tellg();
	int length = end-begin;
	file.seekg(0, ios::beg);
	if(length > 0xDFF)
	{
		#ifdef LOGGING_CHIP8
		mainLog.message = "TEH FILE IS TOOO BIG ABOOOORTT LOADINGGG!!!\n";
		mainLog.writeMessage();
		#endif
		return;
	}
	char readArray[0xDFF] = {0x00};
	for(int a = 0; a < 0xDFF; a++)
	{
		readArray[a] = 0;
	}
	file.read(readArray, length);
	#ifdef LOGGING_CHIP8
	if((file.fail() != 0))
	{
		mainLog.message = "FAILURE AHAHAHAHAHAAHHAHA GOTCHA (TEH ROM WONT REAAD!!!)\n";
		mainLog.writeMessage();
	}

 Tells me the rom wont read. Somewhere something is throwing a bad bit or something similar. Seeing as how this only occurs in release debugging is insanely difficult. Now note that the following code runs completely fine.

std::ifstream file;
	char filenamechars[0x200];
	strcpy(filenamechars, filePath.c_str());
	file.open(filenamechars);
	if (!file.is_open())
	{
		#ifdef LOGGING_CHIP8
		mainLog.message = "This ROM seems to not be opening... ITS LIKE ITS NOT THERE!!! :O\n";
		mainLog.writeMessage();
		#endif
		return false;
	}
	else
	{
		file.close();
		#ifdef LOGGING_CHIP8
		mainLog.message = "This ROM opens! :D\n";
		mainLog.writeMessage();
		#endif
		return true;
	}

 Very strange no?

Contributor
Posts: 10
Registered: ‎11-14-2011
My Device: Blackberry Playbook
My Carrier: T-Mobile

Re: File Problem with app folder

I narrowed it down and the problem is that it simply is not opening the file with out and binary in it. Perhaps QNX is freaking out that I opened it as a binary file? Really strange.

Contributor
Posts: 10
Registered: ‎11-14-2011
My Device: Blackberry Playbook
My Carrier: T-Mobile

Re: File Problem with app folder

[ Edited ]

I am an **bleep**... (EDIT: I didnt know calling myself not intelligent was censorable but okay Smiley Very Happy)
The iosout opens it as write and the folder is read only so yes QNX did freak out. Case solved. 

Should have used the following file opening line. Surprised debug lets this one go.

file.open(filenamechars, std::ios::in | std::ios::binary);

 Onward to the finish line!

Retired
Posts: 45
Registered: ‎10-25-2010
My Device: Bold 9700
My Carrier: Rogers

Re: File Problem with app folder

This is by design: when your app is installed in development mode (whether debugging or not), you can make changes to its assets to resolve run-time problems as quickly as possible, without a long packaging and deployment cycle.

The assets of a release mode app are frozen.