summaryrefslogtreecommitdiff
path: root/src/lib/eio
diff options
context:
space:
mode:
authorVincent Torri <vincent.torri@gmail.com>2019-07-28 09:38:26 +0100
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2019-07-28 09:38:26 +0100
commit5b51a6bb207dc8d5127fa9c6ad7d3c8c6e2659cf (patch)
treec38071eeb0e7c8e610de91796a39b64caf4fb270 /src/lib/eio
parenta6ade14c5e65ab729b1013388ec1aea4be22afc7 (diff)
Eio: enable eio_file_chown if chown is available on the platform
Test Plan: compilation on Windows Reviewers: zmike, raster, cedric Reviewed By: raster Subscribers: #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D9393
Diffstat (limited to 'src/lib/eio')
-rw-r--r--src/lib/eio/Eio_Legacy.h3
-rw-r--r--src/lib/eio/eio_single.c22
2 files changed, 16 insertions, 9 deletions
diff --git a/src/lib/eio/Eio_Legacy.h b/src/lib/eio/Eio_Legacy.h
index ac7a814..50140ed 100644
--- a/src/lib/eio/Eio_Legacy.h
+++ b/src/lib/eio/Eio_Legacy.h
@@ -394,6 +394,9 @@ EAPI Eio_File *eio_file_chmod(const char *path,
394 * 394 *
395 * This function will change the owner of a path, setting it to the user and 395 * This function will change the owner of a path, setting it to the user and
396 * group passed as argument. It's equivalent to the chown shell command. 396 * group passed as argument. It's equivalent to the chown shell command.
397 *
398 * @note Some platforms (including Windows) do not support chown(). In that
399 * case, this function returns @c NULL.
397 */ 400 */
398EAPI Eio_File *eio_file_chown(const char *path, 401EAPI Eio_File *eio_file_chown(const char *path,
399 const char *user, 402 const char *user,
diff --git a/src/lib/eio/eio_single.c b/src/lib/eio/eio_single.c
index 1701f10..3fd11a5 100644
--- a/src/lib/eio/eio_single.c
+++ b/src/lib/eio/eio_single.c
@@ -204,16 +204,10 @@ _eio_file_chmod(void *data, Ecore_Thread *thread)
204 eio_file_thread_error(&ch->common, thread); 204 eio_file_thread_error(&ch->common, thread);
205} 205}
206 206
207#if defined(HAVE_CHOWN) && defined(HAVE_GETPWENT)
207static void 208static void
208_eio_file_chown(void *data, Ecore_Thread *thread) 209_eio_file_chown(void *data, Ecore_Thread *thread)
209{ 210{
210#ifdef _WIN32
211 /* FIXME:
212 * look at http://wwwthep.physik.uni-mainz.de/~frink/chown/readme.html
213 */
214 (void)data;
215 (void)thread;
216#else
217 Eio_File_Chown *own = data; 211 Eio_File_Chown *own = data;
218 char *tmp; 212 char *tmp;
219 uid_t owner = -1; 213 uid_t owner = -1;
@@ -266,7 +260,6 @@ _eio_file_chown(void *data, Ecore_Thread *thread)
266 on_error: 260 on_error:
267 ecore_thread_cancel(thread); 261 ecore_thread_cancel(thread);
268 return; 262 return;
269#endif
270} 263}
271 264
272static void 265static void
@@ -297,6 +290,7 @@ _eio_file_chown_error(void *data, Ecore_Thread *thread EINA_UNUSED)
297 eio_file_error(&ch->common); 290 eio_file_error(&ch->common);
298 _eio_chown_free(ch); 291 _eio_chown_free(ch);
299} 292}
293#endif
300 294
301/** 295/**
302 * @endcond 296 * @endcond
@@ -585,6 +579,7 @@ eio_file_chown(const char *path,
585 Eio_Error_Cb error_cb, 579 Eio_Error_Cb error_cb,
586 const void *data) 580 const void *data)
587{ 581{
582#if defined(HAVE_CHOWN) && defined(HAVE_GETPWENT)
588 Eio_File_Chown *c = NULL; 583 Eio_File_Chown *c = NULL;
589 584
590 EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL); 585 EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
@@ -601,11 +596,20 @@ eio_file_chown(const char *path,
601 if (!eio_file_set(&c->common, 596 if (!eio_file_set(&c->common,
602 done_cb, 597 done_cb,
603 error_cb, 598 error_cb,
604 data, 599 data,
605 _eio_file_chown, 600 _eio_file_chown,
606 _eio_file_chown_done, 601 _eio_file_chown_done,
607 _eio_file_chown_error)) 602 _eio_file_chown_error))
608 return NULL; 603 return NULL;
609 604
610 return &c->common; 605 return &c->common;
606#else
607 EINA_SAFETY_ON_NULL_RETURN_VAL(error_cb, NULL);
608 error_cb(data, NULL, EINVAL);
609 return NULL;
610 (void)path;
611 (void)user;
612 (void)group;
613 (void)done_cb;
614#endif
611} 615}