Why IFILEMGR_OpenFile doesnt work? | developer.brewmp.com Why IFILEMGR_OpenFile doesnt work? | developer.brewmp.com

Developer

Why IFILEMGR_OpenFile doesnt work?

Forums:

I always receive unknow error when try open a new file. I use brew 3.0.1 on simulator. See the code below, please give me your idea to show me where is my error:

int ret = ECLASSNOTSUPPORT;
IFileMgr *pFm;
IFile *pF = NULL;

if (ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_FILEMGR, (void **)&pFm)) {
log("CreateInstance error");
return ret;

pF = IFILEMGR_OpenFile(pFm,"test.txt", _OFM_CREATE );
if ( pF == NULL) {
//Error
log("OpenFile error");
err = IFILEMGR_GetLastError(pFm);
switch (err) {
case EFILEEXISTS:
log("File exists");
break;
case EFILENOEXISTS:
log("File does not exist");
break;
case EDIRNOTEMPTY:
log("Directory not empty");
break;
case EBADFILENAME:
log("Bad file name");
break;
case EBADSEEKPOS:
log("Bad seek position");
break;
case EFILEEOF:
log("End of file");
break;
case EFSFULL:
log("File system full");
break;
case EFILEOPEN:
log("File already open");
break;
case EBADPARM:
log("Bad param");
break;
default:
log("Unknow error");
break;
}
return ret;

wc = IFILE_Write(pF,str,len);

May I need configure something?
Thanks

Check if MIF has the necessary prviliges
Also do u mean that when u get unknown error, the statement at which this error is encountered is the case in the switch statement. ( Check this through the debugger )

Check if MIF has the necessary prviliges
Also do u mean that when u get unknown error, the statement at which this error is encountered is the case in the switch statement. ( Check this through the debugger )

Oh this my error. MIF not enough privileges. You are so great. Thank you very much

Oh this my error. MIF not enough privileges. You are so great. Thank you very much

But, my mif has ALL privileges...

But, my mif has ALL privileges...

Print out the error code and look at it.

Print out the error code and look at it.

If i want to write to some file:
// file manager instance is already successfully created
int open_mode = _OFM_READWRITE;
IFile* File = IFILEMGR_OpenFile(FileManager,Filename,open_mode);
returns:
EFILENOEXISTS
so, I'm truing to create this file:
open mode = _OFM_CREATE
File = IFILEMGR_OpenFile(FileManager,Filename,open_mode);
...and getting Unknown Error - or, simply, there is no valid state for
switching by res after:
int res = IFILEMGR_GetLastError(FileManager);
---------------------
So, following my curiosity, I've made this code:
// ...part of my class "FileReader..."
boolean getFileList(char* buff, char *alt_path, int buff_sz, int max_files = 0){
//alt_path is unused yet...
// buff = where to pu file list,separated by '\n'
// buff_sz - size of buffer
// max_files - if greater than zero - stop after fiding max_files number files...
// ensure in something... somehow...
if (!buff || buff_sz < 1 || max_files < 0)
{
return FALSE;
};
// is manager up?
if (FileManager == 0)
{
if( !callFileManager() ) return FALSE;
};
// c'mon, let's burn it out!
// init enumerating files in "" (application) dir...
if( IFILEMGR_EnumInit(FileManager,"", FALSE) != SUCCESS)
{
DBGPRINTF("FileReader::getFileList: shit! i'm clearing out of this filesystem. bye!");
};
boolean files_available_and_buffer_is_ok = TRUE; // hope so...
FileInfo Finfo;
char _filename[256];
int couter = 0;
STRCPY(buff,"");
max_files = (max_files == 0) ? MAX_INT32 : max_files;
while (files_available_and_buffer_is_ok)
{
if(IFILEMGR_EnumNext(FileManager, &Finfo) ){
SPRINTF(_filename,"%d : %s\n",++couter, Finfo.szName );
if (STRLEN(_filename) <= (buff_sz - STRLEN(buff)) && couter < max_files )
{
STRCAT(buff,_filename);
}else files_available_and_buffer_is_ok = FALSE;
}else files_available_and_buffer_is_ok = FALSE;
}
}
...and all the time I'm getting error: FileReader::getFileList: shit! i'm clearing out of this filesystem. bye!
which means - IFILEMGR_EnumInit had no success...
IMPORTANT:
This all I'm doing on simulator, BREW version 3.1.5
Maybe, simulator does't support file operations of need additional setup?
Privileges in mif is ok (All/System)

If i want to write to some file:
// file manager instance is already successfully created
int open_mode = _OFM_READWRITE;
IFile* File = IFILEMGR_OpenFile(FileManager,Filename,open_mode);
returns:
EFILENOEXISTS
so, I'm truing to create this file:
open mode = _OFM_CREATE
File = IFILEMGR_OpenFile(FileManager,Filename,open_mode);
...and getting Unknown Error - or, simply, there is no valid state for
switching by res after:
int res = IFILEMGR_GetLastError(FileManager);
---------------------
So, following my curiosity, I've made this code:
// ...part of my class "FileReader..."
boolean getFileList(char* buff, char *alt_path, int buff_sz, int max_files = 0){
//alt_path is unused yet...
// buff = where to pu file list,separated by '\n'
// buff_sz - size of buffer
// max_files - if greater than zero - stop after fiding max_files number files...
// ensure in something... somehow...
if (!buff || buff_sz < 1 || max_files < 0)
{
return FALSE;
};
// is manager up?
if (FileManager == 0)
{
if( !callFileManager() ) return FALSE;
};
// c'mon, let's burn it out!
// init enumerating files in "" (application) dir...
if( IFILEMGR_EnumInit(FileManager,"", FALSE) != SUCCESS)
{
DBGPRINTF("FileReader::getFileList: shit! i'm clearing out of this filesystem. bye!");
};
boolean files_available_and_buffer_is_ok = TRUE; // hope so...
FileInfo Finfo;
char _filename[256];
int couter = 0;
STRCPY(buff,"");
max_files = (max_files == 0) ? MAX_INT32 : max_files;
while (files_available_and_buffer_is_ok)
{
if(IFILEMGR_EnumNext(FileManager, &Finfo) ){
SPRINTF(_filename,"%d : %s\n",++couter, Finfo.szName );
if (STRLEN(_filename) <= (buff_sz - STRLEN(buff)) && couter < max_files )
{
STRCAT(buff,_filename);
}else files_available_and_buffer_is_ok = FALSE;
}else files_available_and_buffer_is_ok = FALSE;
}
}
...and all the time I'm getting error: FileReader::getFileList: shit! i'm clearing out of this filesystem. bye!
which means - IFILEMGR_EnumInit had no success...
IMPORTANT:
This all I'm doing on simulator, BREW version 3.1.5
Maybe, simulator does't support file operations of need additional setup?
Privileges in mif is ok (All/System)

Check this thread
http://brewforums.qualcomm.com/showthread.php?p=58391
I hope this solves ur problem

Check this thread
http://brewforums.qualcomm.com/showthread.php?p=58391
I hope this solves ur problem

Unmesh wrote:Check if MIF has the necessary prviliges
Also do u mean that when u get unknown error, the statement at which this error is encountered is the case in the switch statement. ( Check this through the debugger )
My extension doesn't allow me to select a priviliges. Should it gain its rights though the application which is using the extension?
Thanks,
Mike.

Unmesh wrote:Check if MIF has the necessary prviliges
Also do u mean that when u get unknown error, the statement at which this error is encountered is the case in the switch statement. ( Check this through the debugger )
My extension doesn't allow me to select a priviliges. Should it gain its rights though the application which is using the extension?
Thanks,
Mike.