reading initialization file | developer.brewmp.com reading initialization file | developer.brewmp.com

Developer

reading initialization file

Forums:

I tried to read contents from an initialization file, my application crashed. But when i tried the file operations with a normal file, it worked fine. Initialization files are normal text file :confused: , but it is not working. Can anybody help me?

There's a bug in your code. Have you tried debugging?

There's a bug in your code. Have you tried debugging?

It is not getting th size of the file.. IFILE_GetInfo(pIFile, pFileInfo) fails i think.

It is not getting th size of the file.. IFILE_GetInfo(pIFile, pFileInfo) fails i think.

What are the error codes? Do you have a code snippet?

What are the error codes? Do you have a code snippet?

IFileMgr * pIFileMgr= NULL ;
IFile * pIFile = NULL;
FileInfo * pFileInfo = NULL;
AECHAR * pBuffer = NULL;
void *pDataBytes;
pFileInfo = (FileInfo *)MALLOC(sizeof(FileInfo));
if(ISHELL_CreateInstance(pMe->pIShell,AEECLSID_FILEMGR,(void **)&pIFileMgr)==SUCCESS);
{
DBGPRINTF("main screen");
}
pIFile = IFILEMGR_OpenFile(pIFileMgr, "browser.txt", _OFM_READ);
if (!pIFile)
{
FREEIF(pFileInfo);
}
IFILE_GetInfo(pIFile, pFileInfo);
pDataBytes = (void *)MALLOC(pFileInfo->dwSize);
IFILE_Read(pIFile, pDataBytes, pFileInfo->dwSize);
DBGPRINTF("%s", pDataBytes);
FREEIF(pFileInfo);
IFILE_Release(pIFile);
IFILEMGR_Release(pIFileMgr);
Im not getting any error messages. When i run the application, i get a message "module failed to free all memory"..

IFileMgr * pIFileMgr= NULL ;
IFile * pIFile = NULL;
FileInfo * pFileInfo = NULL;
AECHAR * pBuffer = NULL;
void *pDataBytes;
pFileInfo = (FileInfo *)MALLOC(sizeof(FileInfo));
if(ISHELL_CreateInstance(pMe->pIShell,AEECLSID_FILEMGR,(void **)&pIFileMgr)==SUCCESS);
{
DBGPRINTF("main screen");
}
pIFile = IFILEMGR_OpenFile(pIFileMgr, "browser.txt", _OFM_READ);
if (!pIFile)
{
FREEIF(pFileInfo);
}
IFILE_GetInfo(pIFile, pFileInfo);
pDataBytes = (void *)MALLOC(pFileInfo->dwSize);
IFILE_Read(pIFile, pDataBytes, pFileInfo->dwSize);
DBGPRINTF("%s", pDataBytes);
FREEIF(pFileInfo);
IFILE_Release(pIFile);
IFILEMGR_Release(pIFileMgr);
Im not getting any error messages. When i run the application, i get a message "module failed to free all memory"..

you say that the IFILE_GetInfo API is giving an error right use IFILEMGR_GetLastError API and post the int value it is returning.

you say that the IFILE_GetInfo API is giving an error right use IFILEMGR_GetLastError API and post the int value it is returning.

Yeah, you need to check error values. Also, I don't think you're freeing pDataBytes.

Yeah, you need to check error values. Also, I don't think you're freeing pDataBytes.

The error value i get is 0x4488f0. Its an invalid file version. Im trying to open a configuration settings file.

The error value i get is 0x4488f0. Its an invalid file version. Im trying to open a configuration settings file.

The problem is solved. My file name should be "browser.ini".

The problem is solved. My file name should be "browser.ini".