* eio: oops, forgot to add those files.

SVN revision: 51800
This commit is contained in:
Cedric BAIL 2010-09-01 08:23:15 +00:00
parent c85dffafd8
commit eeafcb3be5
3 changed files with 213 additions and 0 deletions

View File

@ -0,0 +1,34 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "eio_private.h"
#include "Eio.h"
static int _eio_count = 0;
EAPI int
eio_init(void)
{
_eio_count++;
if (_eio_count > 1) return _eio_count;
eina_init();
ecore_init();
return _eio_count;
}
EAPI int
eio_shutdown(void)
{
_eio_count--;
if (_eio_count > 0) return _eio_count;
ecore_shutdown();
eina_shutdown();
return _eio_count;
}

View File

@ -0,0 +1,52 @@
#ifndef EIO_PRIVATE_H_
#define EIO_PRIVATE_H_
#include <Ecore.h>
#include "Eio.h"
typedef struct _Eio_File_Ls Eio_File_Ls;
typedef struct _Eio_File_Direct_Ls Eio_File_Direct_Ls;
typedef struct _Eio_File_Char_Ls Eio_File_Char_Ls;
typedef struct _Eio_File_Mkdir Eio_File_Mkdir;
struct _Eio_File
{
Ecore_Thread *thread;
const void *data;
Eio_Done_Cb done_cb;
Eio_Done_Cb error_cb;
};
struct _Eio_File_Ls
{
Eio_File common;
const char *directory;
};
struct _Eio_File_Direct_Ls
{
Eio_File_Ls ls;
Eio_Filter_Direct_Cb filter_cb;
Eio_Main_Direct_Cb main_cb;
};
struct _Eio_File_Char_Ls
{
Eio_File_Ls ls;
Eio_Filter_Cb filter_cb;
Eio_Main_Cb main_cb;
};
struct _Eio_File_Mkdir
{
Eio_File common;
const char *path;
mode_t mode;
};
#endif

View File

@ -0,0 +1,127 @@
/* 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/>.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "eio_private.h"
#include "Eio.h"
static void
_eio_file_mkdir_done(void *data)
{
Eio_File_Mkdir *r = data;
if (r->common.done_cb)
r->common.done_cb(r->common.data);
eina_stringshare_del(r->path);
free(r);
}
static void
_eio_file_mkdir_error(void *data)
{
Eio_File_Mkdir *r = data;
if (r->common.error_cb)
r->common.error_cb(r->common.data);
eina_stringshare_del(r->path);
free(r);
}
static void
_eio_file_mkdir(void *data)
{
Eio_File_Mkdir *r = data;
if (mkdir(r->path, r->mode) != 0)
ecore_thread_cancel(r->common.thread);
}
/* ---- */
EAPI Eio_File *
eio_file_direct_stat(const char *path,
Eio_Stat_Cb done_cb,
Eio_Done_Cb error_cb,
const void *data)
{
return NULL;
}
EAPI Eio_File *
eio_file_unlink(const char *path,
Eio_Done_Cb done_cb,
Eio_Done_Cb error_cb,
const void *data)
{
return NULL;
}
/**
* @brief Create a new directory.
* @param path The directory path to create.
* @param mode The permission to set, follow (mode & ~umask & 0777).
* @param done_cb Callback called from the main loop when the directory has been created.
* @param error_cb Callback called from the main loop when the directory failed to be created or has been canceled.
* @return A reference to the IO operation.
*
* eio_file_mkdir basically call mkdir in another thread. This prevent any lock in your apps.
*/
EAPI Eio_File *
eio_file_mkdir(const char *path,
mode_t mode,
Eio_Done_Cb done_cb,
Eio_Done_Cb error_cb,
const void *data)
{
Eio_File_Mkdir *r = NULL;
if (!path || !done_cb || !error_cb)
return NULL;
r = malloc(sizeof (Eio_File_Mkdir));
if (!r) return NULL;
r->path = eina_stringshare_add(path);
r->mode = mode;
r->common.done_cb = done_cb;
r->common.error_cb = error_cb;
r->common.data = data;
r->common.thread = ecore_thread_run(_eio_file_mkdir,
_eio_file_mkdir_done,
_eio_file_mkdir_error,
r);
if (!r->common.thread) goto on_error;
return &r->common;
on_error:
eina_stringshare_del(r->path);
free(r);
return NULL;
}