Reading Files


Sector7CSD

Still Fresh
Joined
May 24, 2009
Messages
2
Hi,

I try to read files from the wiz via the standard c++ way and everytime it fails. If I run the application on my PC it will open the file correctly. I searched already the internet for informations and found that some programs use a function called "GpFileOpen" - but for this one, I can't find any headerfile.

Here a small code snippet of what I'm trying to do:
CODE
std::fstream data(File, std::ios::in | std::ios::binary);
if(data.good())
{
// obtain file length
data.seekg(-1, std::ios::end);
int Length = (int)data.tellg()+1;

// read file once
data.seekg(0, std::ios::beg);
char * pSong = new char[Length];
data.read(pSong, Length);
data.close();
}


fopen will also fail. I assume that the current directory is set to the directory where my executable lies. The file lies in the same directory as the executable.

Does someone know what I do wrong ?
 
Sector 7 posted on May 24 2009 at 07:24 AM said:
I assume that the current directory is set to the directory where my executable lies. The file lies in the same directory as the executable.
I don't think thats true, unfortunately. Try pre-pending "/mnt/sd/" to your filenames.
 
Last edited by a moderator:
Problem solved, project file recreated. May be I did something wrong in my IDE during the clean up operation of the default code which dev c++ creates.
 
Back
Top