forked from enlightenment/efl
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
This commit is contained in:
parent
a6ade14c5e
commit
5b51a6bb20
|
@ -78,6 +78,7 @@ function_checks = [
|
||||||
['alloca', ['alloca.h']],
|
['alloca', ['alloca.h']],
|
||||||
['backtrace', ['execinfo.h']],
|
['backtrace', ['execinfo.h']],
|
||||||
['backtrace_symbols', ['execinfo.h']],
|
['backtrace_symbols', ['execinfo.h']],
|
||||||
|
['chown', ['unistd.h']],
|
||||||
['clock_gettime', ['time.h']],
|
['clock_gettime', ['time.h']],
|
||||||
['dirfd', ['dirent.h sys/types.h']],
|
['dirfd', ['dirent.h sys/types.h']],
|
||||||
['fchmod', ['sys/stat.h']],
|
['fchmod', ['sys/stat.h']],
|
||||||
|
|
|
@ -394,6 +394,9 @@ EAPI Eio_File *eio_file_chmod(const char *path,
|
||||||
*
|
*
|
||||||
* This function will change the owner of a path, setting it to the user and
|
* This function will change the owner of a path, setting it to the user and
|
||||||
* group passed as argument. It's equivalent to the chown shell command.
|
* group passed as argument. It's equivalent to the chown shell command.
|
||||||
|
*
|
||||||
|
* @note Some platforms (including Windows) do not support chown(). In that
|
||||||
|
* case, this function returns @c NULL.
|
||||||
*/
|
*/
|
||||||
EAPI Eio_File *eio_file_chown(const char *path,
|
EAPI Eio_File *eio_file_chown(const char *path,
|
||||||
const char *user,
|
const char *user,
|
||||||
|
|
|
@ -204,16 +204,10 @@ _eio_file_chmod(void *data, Ecore_Thread *thread)
|
||||||
eio_file_thread_error(&ch->common, thread);
|
eio_file_thread_error(&ch->common, thread);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(HAVE_CHOWN) && defined(HAVE_GETPWENT)
|
||||||
static void
|
static void
|
||||||
_eio_file_chown(void *data, Ecore_Thread *thread)
|
_eio_file_chown(void *data, Ecore_Thread *thread)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
|
||||||
/* FIXME:
|
|
||||||
* look at http://wwwthep.physik.uni-mainz.de/~frink/chown/readme.html
|
|
||||||
*/
|
|
||||||
(void)data;
|
|
||||||
(void)thread;
|
|
||||||
#else
|
|
||||||
Eio_File_Chown *own = data;
|
Eio_File_Chown *own = data;
|
||||||
char *tmp;
|
char *tmp;
|
||||||
uid_t owner = -1;
|
uid_t owner = -1;
|
||||||
|
@ -266,7 +260,6 @@ _eio_file_chown(void *data, Ecore_Thread *thread)
|
||||||
on_error:
|
on_error:
|
||||||
ecore_thread_cancel(thread);
|
ecore_thread_cancel(thread);
|
||||||
return;
|
return;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -297,6 +290,7 @@ _eio_file_chown_error(void *data, Ecore_Thread *thread EINA_UNUSED)
|
||||||
eio_file_error(&ch->common);
|
eio_file_error(&ch->common);
|
||||||
_eio_chown_free(ch);
|
_eio_chown_free(ch);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @endcond
|
* @endcond
|
||||||
|
@ -585,6 +579,7 @@ eio_file_chown(const char *path,
|
||||||
Eio_Error_Cb error_cb,
|
Eio_Error_Cb error_cb,
|
||||||
const void *data)
|
const void *data)
|
||||||
{
|
{
|
||||||
|
#if defined(HAVE_CHOWN) && defined(HAVE_GETPWENT)
|
||||||
Eio_File_Chown *c = NULL;
|
Eio_File_Chown *c = NULL;
|
||||||
|
|
||||||
EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
|
EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
|
||||||
|
@ -601,11 +596,20 @@ eio_file_chown(const char *path,
|
||||||
if (!eio_file_set(&c->common,
|
if (!eio_file_set(&c->common,
|
||||||
done_cb,
|
done_cb,
|
||||||
error_cb,
|
error_cb,
|
||||||
data,
|
data,
|
||||||
_eio_file_chown,
|
_eio_file_chown,
|
||||||
_eio_file_chown_done,
|
_eio_file_chown_done,
|
||||||
_eio_file_chown_error))
|
_eio_file_chown_error))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return &c->common;
|
return &c->common;
|
||||||
|
#else
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN_VAL(error_cb, NULL);
|
||||||
|
error_cb(data, NULL, EINVAL);
|
||||||
|
return NULL;
|
||||||
|
(void)path;
|
||||||
|
(void)user;
|
||||||
|
(void)group;
|
||||||
|
(void)done_cb;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue