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
New Developer
PlayBookDave
Posts: 52
Registered: ‎01-09-2012
My Device: PlayBook

FileBrowseDialog not returning filepaths in usable form

Hello I'm trying implement a FileBroseDialog in an app, partial excepts follows.. while in the dialog_event_get_filebrowse_filepaths Event I'm getting alot of what seems be garbage from the event that should from what i thought be returning file paths to the selected files.


Am i implementing that part wrong ...or what else should be added to get the file paths of each file selected ?


Thanks

 

static void

show_dialog ()

{

if(create_dialog) {

 

}

if

(dialog_create_filebrowse(&create_dialog) != BPS_SUCCESS) {

 

 {fprintf(stderr, "Failed to create dialog.");

 

return;

 

const char* Ext[3];

Ext[0]="*.txt";

Ext[1]="*.jpg";

Ext[2]="*.*";

 

if(dialog_set_filebrowse_filter(create_dialog,Ext,3)!=BPS_SUCCESS)

{

 

fprintf(stderr, "Failed to set dialog filters.");

 

printf("Dialog Filter error: %s\n", strerror(errno));

 

dialog_destroy(create_dialog);

create_dialog=0;

return;

}

bool yes=true;

if(dialog_set_filebrowse_multiselect(create_dialog,yes)!=BPS_SUCCESS)

{

 

fprintf(stderr, "Failed to set dialog multiselect option.");

 

printf("Dialog failed Set MultiSelect error: %s\n", strerror(errno));

 

dialog_destroy(create_dialog);

create_dialog=0;

return;

}

 

if (dialog_show(create_dialog) != BPS_SUCCESS) {

 

fprintf(stderr, "Failed to show dialog.");

 

dialog_destroy(create_dialog);

create_dialog = 0;

return;

}

 

static void handle_event () {

int rc, domain;

for(;:smileywink: {

bps_event_t *event = NULL;

rc = bps_get_event(&event, -1);

assert(rc == BPS_SUCCESS);

if (event) {

           domain = bps_event_get_domain(event);

if (domain == navigator_get_domain()) {

          handle_navigator_event(event);

} elseif (domain == screen_get_domain()) {

handle_screen_event(event);

} elseif (domain == dialog_get_domain()) {

handle_dialog_response(event);

}

}else {

break;

      }

   }

}

/*** Handle a dialog response.

*/

static

void handle_dialog_response (bps_event_t*event) {

/*

* Double check that the event is valid

*/

if(event == NULL) {

 

return;

}

int *num_paths=0;

char file_paths[50]; // = "I put some text here .";char *pCarrier[sizeof(file_paths)];

 

for (i = 0; i < sizeof(file_paths); i++)

pCarrier[i] = &file_paths[i];

if ( dialog_event_get_filebrowse_filepaths(event, pCarrier, &num_paths)!= BPS_SUCCESS) {

fprintf

(stderr, "Failed to set dialog multiselect option.");

 

printf("Dialog failed MultiSelectPathReturn error: %s\n", strerror(errno));

 

dialog_destroy(create_dialog);

create_dialog = 0;

return;

}

 

printf(pCarrier,sizeof(pCarrier));

 

Please use plain text.
New Developer
PlayBookDave
Posts: 52
Registered: ‎01-09-2012
My Device: PlayBook

Re: FileBrowseDialog not returning filepaths in usable form

if ( dialog_event_get_filebrowse_filepaths(event, file_paths, &num_paths)!= BPS_SUCCESS) {

 

The array returning the file paths always returns different results for the same file selected in a format i don't know what todo with

 

eg \250\\210&\\000\250\300&\\000\\377\\377\\377\\377\\000\\000\\000\\000\364\275\337x\\000\\000\\000\\000\264\256\337x\\000\320o\\001(\\nj\\001\\000\\000\\000\\000\\000\\000\\000\\000\\001\\000\\000\\001\\003

 eg \250\\030\257\\000\250P\257\\000\\377\\377\\377\\377\\000\\000\\000\\000\364\275\\034x\\000\\000\\000\\000\264\256\\034x\\000\320C\\001(\\n>\\001\\000\\000\\000\\000\\000\\000\\000\\000\\001\\000\\000\\001\\003

 

 

what am i supposed todo to get the filepath to be returned in a recognizable format like shared/documents/file.txt   ? ??

 

Please use plain text.