Privateprofilestrings...

This is a discussion on Privateprofilestrings... within the C++ Programming forums, part of the General Programming Boards category; Ok, I have a problem for some reason, and I've tried many different solutions... still, things aren't working correctly... Objectives: ...

  1. #1
    Registered User
    Join Date
    Mar 2005
    Posts
    7

    Privateprofilestrings...

    Ok, I have a problem for some reason, and I've tried many different solutions... still, things aren't working correctly... Objectives: Generate a list of the files (No problem) | Store the list of files (No problem) | Read back from the list (Problems... :\ )
    I am indexing sound files for a small project I'm working on... Here's some of the code...
    Code:
    void ReadSounds()
    {
    	soundDir = basedir;  //Base Directory for diff. paths
    	soundDir += "sounds\\"; //Sounds folder
    	newSoundDir = newbasedir;
    	newSoundDir += "sounds\\";
        newSoundDir += "CurrentSound.wav";
    	SNDDBG("ReadSounds() Func Called!");
    	SNDDBG("Read Dir: %s",soundDir.c_str());
    	SNDDBG("Write Dir: %s",newSoundDir.c_str());
    	dr.ClearDirs();  // Start fresh on directories
    	dr.GetDirs(soundDir.c_str(),false);  // Make sure we have the folder in memory, but don't look for subdirs
    	dr.ClearFiles();  // Start fresh on files aswell
    	dr.GetFiles("*.wav");  // Get all .wav files, don't need anything else...
    	CSADirRead::SAFileVector &files = dr.Files();  // File array...
    	iNum=0;
    	string fname;
    	string IdxNm = soundDir + "SoundIndex.ini";
    	const char* filex = IdxNm.c_str();
    	// Now we dump to our function using a simple loop :)
    	for(CSADirRead::SAFileVector::iterator fit = files.begin();fit!=files.end();fit++)
    	{
    		fname = (*fit).m_sName.GetString();
    		fname.erase(0,soundDir.length());
    		fname.erase(fname.length()-4,4);
    		vSounds[iNum].dirname = (char*)(*fit).m_sName.GetString();
    		vSounds[iNum].name = fname.c_str();
    		SNDDBG("File Indexed: %s", vSounds[iNum].dirname);
    		SNDDBG("Filename: %s | Number: %d",vSounds[iNum].name,iNum);
    		char theStr[256];
    		sprintf(theStr,"s%d",iNum);
    		WritePrivateProfileString("Sounds",theStr,vSounds[iNum].name,filex);
    		iNum++;
    	}
    }
    That is my base function, it indexes perfectly -- Everything seems to be fine. Then when I change sounds... well, that's another story...
    Code:
    void ChangeSound(int iNum)
    {
    	CopyFile(vSounds[iNum].dirname,newSoundDir.c_str(),FALSE);
    	string IdxNm = soundDir + "SoundIndex.Ini"
    	char tmpStr[128];
    	sprintf(tmpStr,"s%d",iNum);
    	SNDDBG(tmpStr);
    	char theStr[256];
    	GetPrivateProfileString("Sounds",tmpStr,"File Invalid or Does Not Exist",theStr,255,IdxNm.c_str());
    	char tmpx[256];
    	sprintf(tmpx,"Current Sound: %s",theStr);
    	SNDDBG(tmpx);
    }
    There is the problem... I tried just reading from the string vSounds[iNum].name as the string, but that outputs some very odd ascii and sometimes things I've indexed in memory from other functions in other arrays and classes :\
    The ini comes out perfectly, no problems whatsoever everything is fine, but I just get the "File Invalid or Does Not Exist" every time... :\ I know I must be passing up something so obvious that I'm looking it over...
    **EDIT** Just to clear things up a bit, it copies the file over with no problems... just the returning of the name is really getting me... I honestly don't know what else to try... I've exhausted my resources... Any hints or tips possibly?

    Thanks in advance
    anthrax
    Last edited by anthrax759; 07-06-2005 at 01:32 PM.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21