언어 설정

Menu
Sites
Language
Copy the file to the device from the app.

HI!

Copy the file to the device from the app.

app res path : /res/emoticons/happy.jpg

device ( Z1 ) path : /usr/share/emoticons

 

//---------------------------------------------------------------------

#define MSIZE 16777216

int fileCopy(const char* src, const char* dst) {
  FILE *in, *out;
  char* buf;
  size_t len;

  if (!strcmp(src, dst)) return 4;

  if ((in  = fopen(src, "r+")) == NULL) return 1;
  if ((out = fopen(dst, "w+")) == NULL) { fclose(in); return 2; } 

  if ((buf = (char *) malloc(MSIZE)) == NULL) { fclose(in); fclose(out); return 10; } 

  while ( (len = fread(buf, sizeof(char), sizeof(buf), in)) != NULL )
    if (fwrite(buf, sizeof(char), len, out) == 0) {
      fclose(in); fclose(out);
      free(buf);
      //_unlink(dst); 
      return 3;
    }

  fclose(in); fclose(out);
  free(buf); 

  return 0;
}

//-------------------------------------------------------------------------

The files are not copied...

What's the problem? help me....

 

Responses

9 댓글
Jeongsu Kim

copy from /usr/share/emoticons to app/res ? or from app/res to /usr/share/emoticons?

anyway /usr/share/emoticons is read only area.

app/res is read only area, too.

so you can't copy to the directory

시언 박

Then, What place is anywhere that is not read-only?

currently, I tried "mount -o remount, rw /usr/share/emoticons", "chmod 777 /usr/share/emoticons", "sdb root on".

but, pemission denied....

 

Jeongsu Kim

your app directory
+ data
+ shared +data

and

/opt/usr/media

are allowed for app to write files

시언 박

Thank you. Jeongsu!!

Have a good time~!

 

 

Dinal Jivani

Hello 시언 박

I am facing the same problem can you please share your Code please ?

I wantto allow user to upload the image and then copy that image to my folder that is in /opt/usr/media/.new/ ,

 

Please Help , Thank You,

Dinal Jivani

Shaswati Saha

What's the problem you're facing? Please share error code or screenshot of error log. Also please share your code how you're letting your user to upload image.

You may try with a simple idea e.g. keep the image data of uploaded image into a buffer and then write that into the file in your folder(i.e. /opt/usr/media/.new/)

Dinal Jivani

here is my code to upload and display the image , and storing the paths of the image in an array ....

static void
file_select_result(app_control_h request, app_control_h reply, app_control_result_e result, void *user_data)
{
    appdata_s *ad=user_data;
    char **valueOut;
	int ret;
	if (result == APP_CONTROL_RESULT_SUCCEEDED)
		{
			int len;
		    ret=app_control_get_extra_data_array(reply,APP_CONTROL_DATA_SELECTED,&valueOut,&len);

	    	 ad->Images[statVal]=valueOut[0];
	    	 statVal++;

		    for(int i=0; i<len; i++)
		    {
		    	ad->img_path=valueOut[i];

				ad->gic->item_style = "default";
				ad->gic->func.text_get = NULL;
				ad->gic->func.content_get = gengrid_content_get_cb;
				ad->gic->func.state_get = NULL;
				ad->gic->func.del = NULL;

		    	char buf[PATH_MAX];
		    	grid_itemdata_s *id = calloc(sizeof(grid_itemdata_s), 1);
		    	snprintf(buf, sizeof(buf), "%s", valueOut[i]);
		    	id->index = i;
		    	id->path = eina_stringshare_add(buf);
		    	id->ad = ad;
		    	elm_gengrid_item_append(ad->Attach_Display, ad->gic, id, NULL, id);
		    	dlog_print(DLOG_DEBUG, LOG_TAG, "Dinal IMAGE PATH: %s",valueOut[i]);
		    }

		    if (ret == APP_CONTROL_ERROR_NONE)
		    {
		        dlog_print(DLOG_INFO, LOG_TAG, "Dinal [app_control_result_cb]Succeeded : Error code - %d || Path - %s ",ret,*valueOut);
		    }
		    else
		    {
		       dlog_print(DLOG_ERROR, LOG_TAG, "Dinal [app_control_result_cb]Failed : Error code - %d || Path - %s",ret,*valueOut);
		    }
		    //elm_bg_file_set(ad->bg,ad->img_path, NULL);
		}

}

void Add_Attachment(void *data, Evas_Object *obj, void *event_info)
{
	app_control_h app_control;
	int ret;
	app_control_create(&app_control);
	app_control_set_operation(app_control, APP_CONTROL_OPERATION_PICK);
	app_control_set_mime(app_control, "image/*"); // or, app_control_set_mime(app_control, "*/*");
	app_control_add_extra_data(app_control, APP_CONTROL_DATA_SELECTION_MODE, "multiple");
	ret = app_control_send_launch_request(app_control, file_select_result, data);
	if ( ret == APP_CONTROL_ERROR_NONE)
	{
	  dlog_print(DLOG_INFO, LOG_TAG, "Dinal Succeeded to launch a file manager picker app.");
	}
	else
	{
	  dlog_print(DLOG_ERROR, LOG_TAG, "Dinal Failed to launch a file manager picker app. error code: %d", ret);
	}
	app_control_destroy(app_control);
}

after the user select the images and that is displayed in grid view, i want to copy those image to my hidden folder on click of submit ( i.e. : /opt/usr/media/.new/ )

What should i perform on the click of submit to copy the Image ?

Dinal Jivani

Anyways thanks for the reply but my issue is solved....using FILE Functions like

fread() and fwrite()

Shaswati Saha

That's great. Please share your findings in detail here if possible, so that it can come to help to other developers stuck in similar type of problem.