summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric Bail <cedric@osg.samsung.com>2017-09-13 10:38:36 -0700
committerCedric Bail <cedric@osg.samsung.com>2017-09-13 10:38:36 -0700
commit430095d4f1aaad51ffbc30c7e323c200c896e926 (patch)
treef9796e148a1e55b94bbe290672ffc764aacf7df2
parentaf452c439d10286e7dcdedb89163c2071eda8d0c (diff)
eina: allow convertion to BLOB from Eina_File Eina_Value by mmap the file.
-rw-r--r--src/lib/eina/eina_value.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/lib/eina/eina_value.c b/src/lib/eina/eina_value.c
index 59d54d8799..6088d63695 100644
--- a/src/lib/eina/eina_value.c
+++ b/src/lib/eina/eina_value.c
@@ -4722,7 +4722,25 @@ _eina_value_type_file_convert_to(const Eina_Value_Type *type EINA_UNUSED, const
4722 filename = eina_file_filename_get(f); 4722 filename = eina_file_filename_get(f);
4723 ret = eina_value_type_pset(convert, convert_mem, &filename); 4723 ret = eina_value_type_pset(convert, convert_mem, &filename);
4724 } 4724 }
4725 else if (convert == EINA_VALUE_TYPE_BLOB)
4726 {
4727 Eina_Value_Blob *c = convert_mem;
4728 const void *m;
4729
4730 m = eina_file_map_all((Eina_File*) f, EINA_FILE_WILLNEED);
4731 if (!m) goto end;
4732
4733 c->ops = EINA_VALUE_BLOB_OPERATIONS_MALLOC;
4734 c->memory = malloc(eina_file_size_get(f));
4735 memcpy((void*)c->memory, m, eina_file_size_get(f));
4736 c->size = eina_file_size_get(f);
4737
4738 eina_file_map_free((Eina_File*)f, (void*)m);
4739
4740 ret = EINA_TRUE;
4741 }
4725 4742
4743 end:
4726 return ret; 4744 return ret;
4727} 4745}
4728 4746