2010-09-01 01:23:15 -07:00
|
|
|
/* EIO - EFL data type library
|
|
|
|
* Copyright (C) 2010 Enlightenment Developers:
|
|
|
|
* Cedric Bail <cedric.bail@free.fr>
|
|
|
|
* Vincent "caro" Torri <vtorri at univ-evry dot fr>
|
|
|
|
* Stephen "okra" Houston <UnixTitan@gmail.com>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library;
|
|
|
|
* if not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2019-05-20 06:10:00 -07:00
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
# include <evil_private.h> /* mkdir */
|
|
|
|
#endif
|
|
|
|
|
2010-09-01 01:23:15 -07:00
|
|
|
#include "eio_private.h"
|
|
|
|
#include "Eio.h"
|
|
|
|
|
2010-10-20 12:17:30 -07:00
|
|
|
/*============================================================================*
|
|
|
|
* Local *
|
|
|
|
*============================================================================*/
|
2010-10-13 03:59:33 -07:00
|
|
|
|
2010-10-20 12:17:30 -07:00
|
|
|
/**
|
|
|
|
* @cond LOCAL
|
|
|
|
*/
|
2010-09-06 08:27:10 -07:00
|
|
|
|
2010-09-01 01:23:15 -07:00
|
|
|
static void
|
2010-11-12 05:28:19 -08:00
|
|
|
_eio_file_mkdir(void *data, Ecore_Thread *thread)
|
2010-09-01 01:23:15 -07:00
|
|
|
{
|
2010-09-06 08:27:10 -07:00
|
|
|
Eio_File_Mkdir *m = data;
|
2010-09-01 01:23:15 -07:00
|
|
|
|
2010-09-06 08:27:10 -07:00
|
|
|
if (mkdir(m->path, m->mode) != 0)
|
2010-10-13 10:46:02 -07:00
|
|
|
eio_file_thread_error(&m->common, thread);
|
2010-09-06 08:27:10 -07:00
|
|
|
}
|
2010-09-01 01:23:15 -07:00
|
|
|
|
2010-09-06 08:27:10 -07:00
|
|
|
static void
|
|
|
|
_eio_mkdir_free(Eio_File_Mkdir *m)
|
|
|
|
{
|
|
|
|
eina_stringshare_del(m->path);
|
2012-08-30 01:52:15 -07:00
|
|
|
eio_file_free(&m->common);
|
2010-09-01 01:23:15 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-12-04 09:40:58 -08:00
|
|
|
_eio_file_mkdir_done(void *data, Ecore_Thread *thread EINA_UNUSED)
|
2010-09-01 01:23:15 -07:00
|
|
|
{
|
2010-09-06 08:27:10 -07:00
|
|
|
Eio_File_Mkdir *m = data;
|
2010-09-01 01:23:15 -07:00
|
|
|
|
2010-09-06 08:27:10 -07:00
|
|
|
if (m->common.done_cb)
|
2010-11-12 06:08:01 -08:00
|
|
|
m->common.done_cb((void*) m->common.data, &m->common);
|
2010-09-01 01:23:15 -07:00
|
|
|
|
2010-09-06 08:27:10 -07:00
|
|
|
_eio_mkdir_free(m);
|
2010-09-01 01:23:15 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-12-04 09:40:58 -08:00
|
|
|
_eio_file_mkdir_error(void *data, Ecore_Thread *thread EINA_UNUSED)
|
2010-09-01 01:23:15 -07:00
|
|
|
{
|
2010-09-06 08:27:10 -07:00
|
|
|
Eio_File_Mkdir *m = data;
|
2010-09-01 01:23:15 -07:00
|
|
|
|
2010-09-06 08:27:10 -07:00
|
|
|
eio_file_error(&m->common);
|
|
|
|
_eio_mkdir_free(m);
|
2010-09-01 01:23:15 -07:00
|
|
|
}
|
|
|
|
|
2010-09-02 06:39:59 -07:00
|
|
|
static void
|
2010-11-12 05:28:19 -08:00
|
|
|
_eio_file_unlink(void *data, Ecore_Thread *thread)
|
2010-09-02 06:39:59 -07:00
|
|
|
{
|
|
|
|
Eio_File_Unlink *l = data;
|
|
|
|
|
|
|
|
if (unlink(l->path) != 0)
|
2010-10-13 10:46:02 -07:00
|
|
|
eio_file_thread_error(&l->common, thread);
|
2010-09-06 08:27:10 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_eio_unlink_free(Eio_File_Unlink *l)
|
|
|
|
{
|
|
|
|
eina_stringshare_del(l->path);
|
2012-08-30 01:52:15 -07:00
|
|
|
eio_file_free(&l->common);
|
2010-09-02 06:39:59 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-12-04 09:40:58 -08:00
|
|
|
_eio_file_unlink_done(void *data, Ecore_Thread *thread EINA_UNUSED)
|
2010-09-02 06:39:59 -07:00
|
|
|
{
|
|
|
|
Eio_File_Unlink *l = data;
|
|
|
|
|
|
|
|
if (l->common.done_cb)
|
2010-11-12 06:08:01 -08:00
|
|
|
l->common.done_cb((void*) l->common.data, &l->common);
|
2010-09-02 06:39:59 -07:00
|
|
|
|
2010-09-06 08:27:10 -07:00
|
|
|
_eio_unlink_free(l);
|
2010-09-02 06:39:59 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-12-04 09:40:58 -08:00
|
|
|
_eio_file_unlink_error(void *data, Ecore_Thread *thread EINA_UNUSED)
|
2010-09-02 06:39:59 -07:00
|
|
|
{
|
|
|
|
Eio_File_Unlink *l = data;
|
|
|
|
|
2010-09-06 08:27:10 -07:00
|
|
|
eio_file_error(&l->common);
|
|
|
|
_eio_unlink_free(l);
|
|
|
|
}
|
2010-09-02 06:39:59 -07:00
|
|
|
|
2012-02-28 01:20:43 -08:00
|
|
|
static void
|
2012-03-30 23:30:08 -07:00
|
|
|
_eio_file_struct_2_eina(Eina_Stat *es, _eio_stat_t *st)
|
2012-02-28 01:20:43 -08:00
|
|
|
{
|
|
|
|
es->dev = st->st_dev;
|
|
|
|
es->ino = st->st_ino;
|
|
|
|
es->mode = st->st_mode;
|
|
|
|
es->nlink = st->st_nlink;
|
|
|
|
es->uid = st->st_uid;
|
|
|
|
es->gid = st->st_gid;
|
|
|
|
es->rdev = st->st_rdev;
|
|
|
|
es->size = st->st_size;
|
2012-03-30 23:30:08 -07:00
|
|
|
#ifdef _WIN32
|
|
|
|
es->blksize = 0;
|
|
|
|
es->blocks = 0;
|
|
|
|
#else
|
2012-02-28 01:20:43 -08:00
|
|
|
es->blksize = st->st_blksize;
|
|
|
|
es->blocks = st->st_blocks;
|
2012-03-30 23:30:08 -07:00
|
|
|
#endif
|
2012-02-28 01:20:43 -08:00
|
|
|
es->atime = st->st_atime;
|
|
|
|
es->mtime = st->st_mtime;
|
|
|
|
es->ctime = st->st_ctime;
|
|
|
|
#ifdef _STAT_VER_LINUX
|
|
|
|
# if (defined __USE_MISC && defined st_mtime)
|
|
|
|
es->atimensec = st->st_atim.tv_nsec;
|
|
|
|
es->mtimensec = st->st_mtim.tv_nsec;
|
|
|
|
es->ctimensec = st->st_ctim.tv_nsec;
|
|
|
|
# else
|
|
|
|
es->atimensec = st->st_atimensec;
|
|
|
|
es->mtimensec = st->st_mtimensec;
|
|
|
|
es->ctimensec = st->st_ctimensec;
|
|
|
|
# endif
|
|
|
|
#else
|
|
|
|
es->atimensec = 0;
|
|
|
|
es->mtimensec = 0;
|
|
|
|
es->ctimensec = 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2010-09-06 08:27:10 -07:00
|
|
|
static void
|
2010-11-12 05:28:19 -08:00
|
|
|
_eio_file_stat(void *data, Ecore_Thread *thread)
|
2010-09-06 08:27:10 -07:00
|
|
|
{
|
|
|
|
Eio_File_Stat *s = data;
|
2012-03-30 23:30:08 -07:00
|
|
|
_eio_stat_t buf;
|
2010-09-06 08:27:10 -07:00
|
|
|
|
2012-03-30 23:30:08 -07:00
|
|
|
if (_eio_stat(s->path, &buf) != 0)
|
2010-10-13 10:46:02 -07:00
|
|
|
eio_file_thread_error(&s->common, thread);
|
2012-02-23 03:46:51 -08:00
|
|
|
|
2012-02-28 01:20:43 -08:00
|
|
|
_eio_file_struct_2_eina(&s->buffer, &buf);
|
|
|
|
}
|
2012-02-23 03:46:51 -08:00
|
|
|
|
2012-02-28 01:20:43 -08:00
|
|
|
static void
|
|
|
|
_eio_file_lstat(void *data, Ecore_Thread *thread)
|
|
|
|
{
|
|
|
|
Eio_File_Stat *s = data;
|
2017-08-14 06:50:03 -07:00
|
|
|
_eio_stat_t buf;
|
2012-02-28 01:20:43 -08:00
|
|
|
|
2013-03-11 12:32:00 -07:00
|
|
|
if (_eio_lstat(s->path, &buf) != 0)
|
2012-02-28 01:20:43 -08:00
|
|
|
eio_file_thread_error(&s->common, thread);
|
|
|
|
|
|
|
|
_eio_file_struct_2_eina(&s->buffer, &buf);
|
2010-09-06 08:27:10 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_eio_stat_free(Eio_File_Stat *s)
|
|
|
|
{
|
|
|
|
eina_stringshare_del(s->path);
|
2012-08-30 01:52:15 -07:00
|
|
|
eio_file_free(&s->common);
|
2010-09-06 08:27:10 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-12-04 09:40:58 -08:00
|
|
|
_eio_file_stat_done(void *data, Ecore_Thread *thread EINA_UNUSED)
|
2010-09-06 08:27:10 -07:00
|
|
|
{
|
|
|
|
Eio_File_Stat *s = data;
|
|
|
|
|
|
|
|
if (s->done_cb)
|
2010-11-12 06:08:01 -08:00
|
|
|
s->done_cb((void*) s->common.data, &s->common, &s->buffer);
|
2010-09-06 08:27:10 -07:00
|
|
|
|
|
|
|
_eio_stat_free(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-12-04 09:40:58 -08:00
|
|
|
_eio_file_stat_error(void *data, Ecore_Thread *thread EINA_UNUSED)
|
2010-09-06 08:27:10 -07:00
|
|
|
{
|
|
|
|
Eio_File_Stat *s = data;
|
|
|
|
|
|
|
|
eio_file_error(&s->common);
|
|
|
|
_eio_stat_free(s);
|
2010-09-02 06:39:59 -07:00
|
|
|
}
|
|
|
|
|
2010-10-20 09:42:45 -07:00
|
|
|
static void
|
2010-11-12 05:28:19 -08:00
|
|
|
_eio_file_chmod(void *data, Ecore_Thread *thread)
|
2010-10-20 09:42:45 -07:00
|
|
|
{
|
|
|
|
Eio_File_Chmod *ch = data;
|
|
|
|
|
|
|
|
if (chmod(ch->path, ch->mode) != 0)
|
|
|
|
eio_file_thread_error(&ch->common, thread);
|
|
|
|
}
|
|
|
|
|
2019-07-28 01:38:26 -07:00
|
|
|
#if defined(HAVE_CHOWN) && defined(HAVE_GETPWENT)
|
2010-10-20 09:42:45 -07:00
|
|
|
static void
|
2010-11-12 05:28:19 -08:00
|
|
|
_eio_file_chown(void *data, Ecore_Thread *thread)
|
2010-10-20 09:42:45 -07:00
|
|
|
{
|
|
|
|
Eio_File_Chown *own = data;
|
|
|
|
char *tmp;
|
|
|
|
uid_t owner = -1;
|
|
|
|
gid_t group = -1;
|
|
|
|
|
|
|
|
own->common.error = 0;
|
|
|
|
|
|
|
|
if (own->user)
|
|
|
|
{
|
|
|
|
owner = strtol(own->user, &tmp, 10);
|
|
|
|
|
|
|
|
if (*tmp != '\0')
|
|
|
|
{
|
|
|
|
struct passwd *pw = NULL;
|
|
|
|
|
|
|
|
own->common.error = EIO_FILE_GETPWNAM;
|
|
|
|
|
|
|
|
pw = getpwnam(own->user);
|
|
|
|
if (!pw) goto on_error;
|
|
|
|
|
|
|
|
owner = pw->pw_uid;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (own->group)
|
|
|
|
{
|
|
|
|
group = strtol(own->group, &tmp, 10);
|
|
|
|
|
|
|
|
if (*tmp != '\0')
|
|
|
|
{
|
|
|
|
struct group *grp = NULL;
|
|
|
|
|
|
|
|
own->common.error = EIO_FILE_GETGRNAM;
|
|
|
|
|
|
|
|
grp = getgrnam(own->group);
|
|
|
|
if (!grp) goto on_error;
|
|
|
|
|
|
|
|
group = grp->gr_gid;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (owner == (uid_t) -1 && group == (gid_t) -1)
|
|
|
|
goto on_error;
|
|
|
|
|
|
|
|
if (chown(own->path, owner, group) != 0)
|
|
|
|
eio_file_thread_error(&own->common, thread);
|
|
|
|
|
2013-06-20 04:28:18 -07:00
|
|
|
return;
|
2010-10-20 09:42:45 -07:00
|
|
|
|
|
|
|
on_error:
|
|
|
|
ecore_thread_cancel(thread);
|
2013-06-20 04:28:18 -07:00
|
|
|
return;
|
2010-10-20 09:42:45 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_eio_chown_free(Eio_File_Chown *ch)
|
|
|
|
{
|
|
|
|
if (ch->user) eina_stringshare_del(ch->user);
|
|
|
|
if (ch->group) eina_stringshare_del(ch->group);
|
|
|
|
eina_stringshare_del(ch->path);
|
2012-08-30 01:52:15 -07:00
|
|
|
eio_file_free(&ch->common);
|
2010-10-20 09:42:45 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-12-04 09:40:58 -08:00
|
|
|
_eio_file_chown_done(void *data, Ecore_Thread *thread EINA_UNUSED)
|
2010-10-20 09:42:45 -07:00
|
|
|
{
|
|
|
|
Eio_File_Chown *ch = data;
|
|
|
|
|
|
|
|
if (ch->common.done_cb)
|
2010-11-12 06:08:01 -08:00
|
|
|
ch->common.done_cb((void*) ch->common.data, &ch->common);
|
2010-10-20 09:42:45 -07:00
|
|
|
|
|
|
|
_eio_chown_free(ch);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-12-04 09:40:58 -08:00
|
|
|
_eio_file_chown_error(void *data, Ecore_Thread *thread EINA_UNUSED)
|
2010-10-20 09:42:45 -07:00
|
|
|
{
|
|
|
|
Eio_File_Chown *ch = data;
|
|
|
|
|
|
|
|
eio_file_error(&ch->common);
|
|
|
|
_eio_chown_free(ch);
|
|
|
|
}
|
2019-07-28 01:38:26 -07:00
|
|
|
#endif
|
2010-10-12 07:59:30 -07:00
|
|
|
|
2010-10-20 12:17:30 -07:00
|
|
|
/**
|
|
|
|
* @endcond
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*============================================================================*
|
|
|
|
* Global *
|
|
|
|
*============================================================================*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @cond LOCAL
|
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
|
|
|
eio_file_error(Eio_File *common)
|
|
|
|
{
|
|
|
|
if (common->error_cb)
|
2010-11-12 06:08:01 -08:00
|
|
|
common->error_cb((void*) common->data, common, common->error);
|
2016-07-15 17:00:33 -07:00
|
|
|
common->thread = NULL;
|
2010-10-20 12:17:30 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
eio_file_thread_error(Eio_File *common, Ecore_Thread *thread)
|
|
|
|
{
|
|
|
|
common->error = errno;
|
|
|
|
ecore_thread_cancel(thread);
|
|
|
|
}
|
|
|
|
|
2012-08-30 01:52:15 -07:00
|
|
|
void
|
|
|
|
eio_file_free(Eio_File *common)
|
|
|
|
{
|
|
|
|
if (common->worker.associated)
|
|
|
|
eina_hash_free(common->worker.associated);
|
|
|
|
if (common->main.associated)
|
|
|
|
eina_hash_free(common->main.associated);
|
2015-01-07 07:43:47 -08:00
|
|
|
eio_file_unregister(common);
|
2015-04-20 05:46:23 -07:00
|
|
|
eio_common_free(common);
|
2012-08-30 01:52:15 -07:00
|
|
|
}
|
|
|
|
|
2010-10-20 12:17:30 -07:00
|
|
|
Eina_Bool
|
|
|
|
eio_long_file_set(Eio_File *common,
|
|
|
|
Eio_Done_Cb done_cb,
|
|
|
|
Eio_Error_Cb error_cb,
|
|
|
|
const void *data,
|
2010-11-12 05:28:19 -08:00
|
|
|
Ecore_Thread_Cb heavy_cb,
|
2010-10-20 12:17:30 -07:00
|
|
|
Ecore_Thread_Notify_Cb notify_cb,
|
2010-11-12 05:28:19 -08:00
|
|
|
Ecore_Thread_Cb end_cb,
|
|
|
|
Ecore_Thread_Cb cancel_cb)
|
2010-10-20 12:17:30 -07:00
|
|
|
{
|
|
|
|
Ecore_Thread *thread;
|
|
|
|
|
|
|
|
common->done_cb = done_cb;
|
|
|
|
common->error_cb = error_cb;
|
|
|
|
common->data = data;
|
|
|
|
common->error = 0;
|
2016-07-31 21:37:25 -07:00
|
|
|
common->length = 0;
|
2010-10-20 12:17:30 -07:00
|
|
|
common->thread = NULL;
|
2011-05-24 03:41:37 -07:00
|
|
|
common->container = NULL;
|
2011-06-07 09:30:10 -07:00
|
|
|
common->worker.associated = NULL;
|
|
|
|
common->main.associated = NULL;
|
2010-10-20 12:17:30 -07:00
|
|
|
|
2010-11-12 05:28:19 -08:00
|
|
|
/* Be aware that ecore_thread_feedback_run could call cancel_cb if something goes wrong.
|
2010-10-20 12:17:30 -07:00
|
|
|
This means that common would be destroyed if thread == NULL.
|
|
|
|
*/
|
|
|
|
thread = ecore_thread_feedback_run(heavy_cb,
|
|
|
|
notify_cb,
|
|
|
|
end_cb,
|
|
|
|
cancel_cb,
|
|
|
|
common,
|
2012-03-10 05:27:44 -08:00
|
|
|
EINA_FALSE);
|
2015-01-07 07:43:47 -08:00
|
|
|
if (thread)
|
|
|
|
{
|
|
|
|
common->thread = thread;
|
|
|
|
eio_file_register(common);
|
|
|
|
}
|
2010-10-20 12:17:30 -07:00
|
|
|
return !!thread;
|
|
|
|
}
|
|
|
|
|
|
|
|
Eina_Bool
|
|
|
|
eio_file_set(Eio_File *common,
|
|
|
|
Eio_Done_Cb done_cb,
|
|
|
|
Eio_Error_Cb error_cb,
|
|
|
|
const void *data,
|
2010-11-12 05:28:19 -08:00
|
|
|
Ecore_Thread_Cb job_cb,
|
|
|
|
Ecore_Thread_Cb end_cb,
|
|
|
|
Ecore_Thread_Cb cancel_cb)
|
2010-10-20 12:17:30 -07:00
|
|
|
{
|
|
|
|
Ecore_Thread *thread;
|
|
|
|
|
|
|
|
common->done_cb = done_cb;
|
|
|
|
common->error_cb = error_cb;
|
|
|
|
common->data = data;
|
|
|
|
common->error = 0;
|
2016-07-31 21:37:25 -07:00
|
|
|
common->length = 0;
|
2010-10-20 12:17:30 -07:00
|
|
|
common->thread = NULL;
|
2011-05-24 03:41:37 -07:00
|
|
|
common->container = NULL;
|
2012-08-30 01:52:15 -07:00
|
|
|
common->worker.associated = NULL;
|
|
|
|
common->main.associated = NULL;
|
2010-10-20 12:17:30 -07:00
|
|
|
|
|
|
|
/* Be aware that ecore_thread_run could call cancel_cb if something goes wrong.
|
|
|
|
This means that common would be destroyed if thread == NULL.
|
|
|
|
*/
|
|
|
|
thread = ecore_thread_run(job_cb, end_cb, cancel_cb, common);
|
|
|
|
|
2015-01-07 07:43:47 -08:00
|
|
|
if (thread)
|
|
|
|
{
|
|
|
|
common->thread = thread;
|
|
|
|
eio_file_register(common);
|
|
|
|
}
|
2010-10-20 12:17:30 -07:00
|
|
|
return !!thread;
|
|
|
|
}
|
|
|
|
|
2011-05-24 03:41:37 -07:00
|
|
|
void
|
|
|
|
eio_file_container_set(Eio_File *common, void *container)
|
|
|
|
{
|
|
|
|
common->container = container;
|
|
|
|
}
|
|
|
|
|
2010-10-20 12:17:30 -07:00
|
|
|
/**
|
|
|
|
* @endcond
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*============================================================================*
|
|
|
|
* API *
|
|
|
|
*============================================================================*/
|
|
|
|
|
2010-09-01 01:23:15 -07:00
|
|
|
EAPI Eio_File *
|
|
|
|
eio_file_direct_stat(const char *path,
|
|
|
|
Eio_Stat_Cb done_cb,
|
2010-09-07 07:43:51 -07:00
|
|
|
Eio_Error_Cb error_cb,
|
2010-09-01 01:23:15 -07:00
|
|
|
const void *data)
|
|
|
|
{
|
2010-09-06 08:27:10 -07:00
|
|
|
Eio_File_Stat *s = NULL;
|
|
|
|
|
2012-12-24 01:44:21 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(done_cb, NULL);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(error_cb, NULL);
|
2010-09-06 08:27:10 -07:00
|
|
|
|
2015-04-20 05:46:23 -07:00
|
|
|
s = eio_common_alloc(sizeof (Eio_File_Stat));
|
2010-09-06 08:27:10 -07:00
|
|
|
if (!s) return NULL;
|
|
|
|
|
|
|
|
s->path = eina_stringshare_add(path);
|
|
|
|
s->done_cb = done_cb;
|
|
|
|
|
2012-06-21 06:56:42 -07:00
|
|
|
if (!eio_file_set(&s->common,
|
2010-09-06 09:37:43 -07:00
|
|
|
NULL,
|
|
|
|
error_cb,
|
|
|
|
data,
|
|
|
|
_eio_file_stat,
|
|
|
|
_eio_file_stat_done,
|
|
|
|
_eio_file_stat_error))
|
2012-08-20 19:22:20 -07:00
|
|
|
/* THERE IS NO MEMLEAK HERE, ECORE_THREAD CANCEL CALLBACK HAS BEEN ALREADY CALLED
|
|
|
|
AND s HAS BEEN FREED, SAME FOR ALL CALL TO EIO_FILE_SET ! */
|
|
|
|
return NULL;
|
2010-09-06 08:27:10 -07:00
|
|
|
|
2012-06-21 06:56:42 -07:00
|
|
|
return &s->common;
|
2010-09-01 01:23:15 -07:00
|
|
|
}
|
|
|
|
|
2012-02-28 01:20:43 -08:00
|
|
|
EAPI Eio_File *
|
|
|
|
eio_file_direct_lstat(const char *path,
|
|
|
|
Eio_Stat_Cb done_cb,
|
|
|
|
Eio_Error_Cb error_cb,
|
|
|
|
const void *data)
|
|
|
|
{
|
|
|
|
Eio_File_Stat *s = NULL;
|
|
|
|
|
2012-12-24 01:44:21 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(done_cb, NULL);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(error_cb, NULL);
|
2012-02-28 01:20:43 -08:00
|
|
|
|
2015-04-20 05:46:23 -07:00
|
|
|
s = eio_common_alloc(sizeof (Eio_File_Stat));
|
2012-02-28 01:20:43 -08:00
|
|
|
if (!s) return NULL;
|
|
|
|
|
|
|
|
s->path = eina_stringshare_add(path);
|
|
|
|
s->done_cb = done_cb;
|
|
|
|
|
2012-06-21 06:56:42 -07:00
|
|
|
if (!eio_file_set(&s->common,
|
2012-02-28 01:20:43 -08:00
|
|
|
NULL,
|
|
|
|
error_cb,
|
|
|
|
data,
|
|
|
|
_eio_file_lstat,
|
|
|
|
_eio_file_stat_done,
|
|
|
|
_eio_file_stat_error))
|
2012-06-21 06:56:42 -07:00
|
|
|
return NULL;
|
2012-02-28 01:20:43 -08:00
|
|
|
|
2012-06-21 06:56:42 -07:00
|
|
|
return &s->common;
|
2012-02-28 01:20:43 -08:00
|
|
|
}
|
|
|
|
|
2010-09-01 01:23:15 -07:00
|
|
|
EAPI Eio_File *
|
|
|
|
eio_file_unlink(const char *path,
|
|
|
|
Eio_Done_Cb done_cb,
|
2010-09-07 07:43:51 -07:00
|
|
|
Eio_Error_Cb error_cb,
|
2010-09-01 01:23:15 -07:00
|
|
|
const void *data)
|
|
|
|
{
|
2010-09-02 06:39:59 -07:00
|
|
|
Eio_File_Unlink *l = NULL;
|
|
|
|
|
2012-12-24 01:44:21 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(done_cb, NULL);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(error_cb, NULL);
|
2010-09-02 06:39:59 -07:00
|
|
|
|
2015-04-20 05:46:23 -07:00
|
|
|
l = eio_common_alloc(sizeof (Eio_File_Unlink));
|
2010-09-02 06:39:59 -07:00
|
|
|
if (!l) return NULL;
|
|
|
|
|
|
|
|
l->path = eina_stringshare_add(path);
|
|
|
|
|
2012-06-21 06:56:42 -07:00
|
|
|
if (!eio_file_set(&l->common,
|
2010-09-06 09:37:43 -07:00
|
|
|
done_cb,
|
|
|
|
error_cb,
|
|
|
|
data,
|
|
|
|
_eio_file_unlink,
|
|
|
|
_eio_file_unlink_done,
|
|
|
|
_eio_file_unlink_error))
|
2012-08-20 19:22:20 -07:00
|
|
|
return NULL;
|
2010-09-02 06:39:59 -07:00
|
|
|
|
2012-06-21 06:56:42 -07:00
|
|
|
return &l->common;
|
2010-09-01 01:23:15 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI Eio_File *
|
|
|
|
eio_file_mkdir(const char *path,
|
|
|
|
mode_t mode,
|
|
|
|
Eio_Done_Cb done_cb,
|
2010-09-07 07:43:51 -07:00
|
|
|
Eio_Error_Cb error_cb,
|
2010-09-01 01:23:15 -07:00
|
|
|
const void *data)
|
|
|
|
{
|
|
|
|
Eio_File_Mkdir *r = NULL;
|
|
|
|
|
2012-12-24 01:44:21 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(done_cb, NULL);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(error_cb, NULL);
|
2010-09-01 01:23:15 -07:00
|
|
|
|
2015-04-20 05:46:23 -07:00
|
|
|
r = eio_common_alloc(sizeof (Eio_File_Mkdir));
|
2010-09-01 01:23:15 -07:00
|
|
|
if (!r) return NULL;
|
|
|
|
|
|
|
|
r->path = eina_stringshare_add(path);
|
|
|
|
r->mode = mode;
|
|
|
|
|
2012-06-21 06:56:42 -07:00
|
|
|
if (!eio_file_set(&r->common,
|
2010-09-06 09:37:43 -07:00
|
|
|
done_cb,
|
|
|
|
error_cb,
|
|
|
|
data,
|
|
|
|
_eio_file_mkdir,
|
|
|
|
_eio_file_mkdir_done,
|
|
|
|
_eio_file_mkdir_error))
|
2012-08-20 19:22:20 -07:00
|
|
|
return NULL;
|
2010-09-01 01:23:15 -07:00
|
|
|
|
2012-06-21 06:56:42 -07:00
|
|
|
return &r->common;
|
2010-09-01 01:23:15 -07:00
|
|
|
}
|
|
|
|
|
2010-10-20 09:42:45 -07:00
|
|
|
EAPI Eio_File *
|
|
|
|
eio_file_chmod(const char *path,
|
|
|
|
mode_t mode,
|
|
|
|
Eio_Done_Cb done_cb,
|
|
|
|
Eio_Error_Cb error_cb,
|
|
|
|
const void *data)
|
|
|
|
{
|
|
|
|
Eio_File_Mkdir *r = NULL;
|
|
|
|
|
2012-12-24 01:44:21 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(done_cb, NULL);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(error_cb, NULL);
|
2010-10-20 09:42:45 -07:00
|
|
|
|
2015-04-20 05:46:23 -07:00
|
|
|
r = eio_common_alloc(sizeof (Eio_File_Mkdir));
|
2010-10-20 09:42:45 -07:00
|
|
|
if (!r) return NULL;
|
|
|
|
|
|
|
|
r->path = eina_stringshare_add(path);
|
|
|
|
r->mode = mode;
|
|
|
|
|
2012-06-21 06:56:42 -07:00
|
|
|
if (!eio_file_set(&r->common,
|
2010-10-20 09:42:45 -07:00
|
|
|
done_cb,
|
|
|
|
error_cb,
|
|
|
|
data,
|
|
|
|
_eio_file_chmod,
|
|
|
|
_eio_file_mkdir_done,
|
|
|
|
_eio_file_mkdir_error))
|
2012-08-20 19:22:20 -07:00
|
|
|
return NULL;
|
2010-10-20 09:42:45 -07:00
|
|
|
|
2012-06-21 06:56:42 -07:00
|
|
|
return &r->common;
|
2010-10-20 09:42:45 -07:00
|
|
|
}
|
|
|
|
|
2011-12-03 05:21:07 -08:00
|
|
|
EAPI Eio_File *
|
|
|
|
eio_file_chown(const char *path,
|
|
|
|
const char *user,
|
|
|
|
const char *group,
|
|
|
|
Eio_Done_Cb done_cb,
|
|
|
|
Eio_Error_Cb error_cb,
|
|
|
|
const void *data)
|
2010-10-20 09:42:45 -07:00
|
|
|
{
|
2019-07-28 01:38:26 -07:00
|
|
|
#if defined(HAVE_CHOWN) && defined(HAVE_GETPWENT)
|
2010-10-20 09:42:45 -07:00
|
|
|
Eio_File_Chown *c = NULL;
|
|
|
|
|
2012-12-24 01:44:21 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(done_cb, NULL);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(error_cb, NULL);
|
2010-10-20 09:42:45 -07:00
|
|
|
|
2015-04-20 05:46:23 -07:00
|
|
|
c = eio_common_alloc(sizeof (Eio_File_Chown));
|
2010-10-20 09:42:45 -07:00
|
|
|
if (!c) return NULL;
|
|
|
|
|
|
|
|
c->path = eina_stringshare_add(path);
|
|
|
|
c->user = eina_stringshare_add(user);
|
|
|
|
c->group = eina_stringshare_add(group);
|
|
|
|
|
2012-06-21 06:56:42 -07:00
|
|
|
if (!eio_file_set(&c->common,
|
2010-10-20 09:42:45 -07:00
|
|
|
done_cb,
|
|
|
|
error_cb,
|
2019-07-28 01:38:26 -07:00
|
|
|
data,
|
2010-10-20 09:42:45 -07:00
|
|
|
_eio_file_chown,
|
|
|
|
_eio_file_chown_done,
|
|
|
|
_eio_file_chown_error))
|
2012-08-20 19:22:20 -07:00
|
|
|
return NULL;
|
2010-10-20 09:42:45 -07:00
|
|
|
|
2012-06-21 06:56:42 -07:00
|
|
|
return &c->common;
|
2019-07-28 01:38:26 -07:00
|
|
|
#else
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(error_cb, NULL);
|
2019-09-12 11:45:58 -07:00
|
|
|
error_cb((char *)data, NULL, EINVAL);
|
2019-07-28 01:38:26 -07:00
|
|
|
return NULL;
|
|
|
|
(void)path;
|
|
|
|
(void)user;
|
|
|
|
(void)group;
|
|
|
|
(void)done_cb;
|
|
|
|
#endif
|
2010-10-20 09:42:45 -07:00
|
|
|
}
|