2010-09-01 01:23:15 -07:00
|
|
|
#ifndef EIO_PRIVATE_H_
|
|
|
|
#define EIO_PRIVATE_H_
|
|
|
|
|
2010-10-12 17:26:12 -07:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_FEATURES_H
|
|
|
|
# include <features.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _FILE_OFFSET_BITS
|
|
|
|
# define _FILE_OFFSET_BITS 64
|
|
|
|
#endif
|
2010-09-01 01:23:15 -07:00
|
|
|
|
2010-10-12 17:26:12 -07:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#ifndef _MSC_VER
|
|
|
|
# include <unistd.h>
|
|
|
|
# include <libgen.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <errno.h>
|
2010-09-06 08:27:10 -07:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
2010-10-12 17:26:12 -07:00
|
|
|
#include <dirent.h>
|
|
|
|
#include <sys/mman.h>
|
|
|
|
#include <fcntl.h>
|
2010-10-20 09:42:45 -07:00
|
|
|
#include <pwd.h>
|
2010-10-21 10:51:21 -07:00
|
|
|
|
|
|
|
#ifdef HAVE_GRP_H
|
|
|
|
# include <grp.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef EFL_HAVE_POSIX_THREADS
|
|
|
|
# include <pthread.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef EFL_HAVE_WIN32_THREADS
|
|
|
|
# include <windows.h>
|
|
|
|
#endif
|
2010-10-12 17:26:12 -07:00
|
|
|
|
|
|
|
#include <Ecore.h>
|
2010-09-06 08:27:10 -07:00
|
|
|
|
2010-09-01 01:23:15 -07:00
|
|
|
#include "Eio.h"
|
|
|
|
|
2010-10-05 04:44:03 -07:00
|
|
|
/* Keeping 32 Eio_File_Progress alive should be enought */
|
|
|
|
#define EIO_PROGRESS_LIMIT 32
|
|
|
|
|
* eio: add eio_file_copy (using splice when available and
fallback to mmap/write with huge tlb when not).
That what an eio_cp would look like :
#include <Ecore.h>
#include <Eio.h>
static void
_test_progress_cb(void *data, const Eio_Progress *info)
{
printf("%f (%zi / %zi octets)\n", info->percent, info->current, info->max);
}
static void
_test_done_cb(void *data)
{
printf("copy done\n");
ecore_main_loop_quit();
}
static void
_test_error_cb(int error, void *data)
{
fprintf(stderr, "error: [%s]\n", strerror(error));
ecore_main_loop_quit();
}
int
main(int argc, char **argv)
{
Eio_File *cp;
if (argc != 3)
{
fprintf(stderr, "eio_cp source_file destination_file\n");
return -1;
}
ecore_init();
eio_init();
cp = eio_file_copy(argv[1], argv[2],
_test_progress_cb,
_test_done_cb,
_test_error_cb,
NULL);
ecore_main_loop_begin();
eio_shutdown();
ecore_shutdown();
return 0;
}
SVN revision: 52787
2010-09-26 14:47:48 -07:00
|
|
|
/* Huge TLB == 16M on most system */
|
|
|
|
#define EIO_PACKET_SIZE 65536
|
|
|
|
#define EIO_PACKET_COUNT 256
|
|
|
|
|
2010-09-01 01:23:15 -07:00
|
|
|
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;
|
2010-10-20 09:42:45 -07:00
|
|
|
typedef struct _Eio_File_Mkdir Eio_File_Chmod;
|
2010-09-02 06:39:59 -07:00
|
|
|
typedef struct _Eio_File_Unlink Eio_File_Unlink;
|
2010-09-06 08:27:10 -07:00
|
|
|
typedef struct _Eio_File_Stat Eio_File_Stat;
|
* eio: add eio_file_move (completly asynchronous and non
blocking move). It first try a rename, then fallback to
an eio_file_copy + eio_file_unlink.
Small example on how to use it :
#include <Ecore.h>
#include <Eio.h>
static void
_test_done_cb(void *data)
{
printf("move done\n");
ecore_main_loop_quit();
}
static void
_test_error_cb(int error, void *data)
{
fprintf(stderr, "error: [%s]\n", strerror(error));
ecore_main_loop_quit();
}
int
main(int argc, char **argv)
{
Eio_File *cp;
if (argc != 3)
{
fprintf(stderr, "eio_cp source_file destination_file\n");
return -1;
}
ecore_init();
eio_init();
cp = eio_file_move(argv[1], argv[2],
NULL,
_test_done_cb,
_test_error_cb,
NULL);
ecore_main_loop_begin();
eio_shutdown();
ecore_shutdown();
return 0;
}
SVN revision: 52845
2010-09-28 02:05:51 -07:00
|
|
|
typedef struct _Eio_File_Progress Eio_File_Progress;
|
|
|
|
typedef struct _Eio_File_Move Eio_File_Move;
|
2010-10-20 09:42:45 -07:00
|
|
|
typedef struct _Eio_File_Chown Eio_File_Chown;
|
2010-09-01 01:23:15 -07:00
|
|
|
|
2010-10-05 04:44:03 -07:00
|
|
|
typedef struct _Eio_Dir_Copy Eio_Dir_Copy;
|
|
|
|
|
2010-09-01 01:23:15 -07:00
|
|
|
struct _Eio_File
|
|
|
|
{
|
|
|
|
Ecore_Thread *thread;
|
|
|
|
const void *data;
|
|
|
|
|
2010-09-07 07:43:51 -07:00
|
|
|
int error;
|
|
|
|
|
|
|
|
Eio_Error_Cb error_cb;
|
2010-09-01 01:23:15 -07:00
|
|
|
Eio_Done_Cb done_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;
|
|
|
|
};
|
|
|
|
|
2010-09-02 06:39:59 -07:00
|
|
|
struct _Eio_File_Unlink
|
|
|
|
{
|
|
|
|
Eio_File common;
|
|
|
|
|
|
|
|
const char *path;
|
|
|
|
};
|
|
|
|
|
2010-09-06 08:27:10 -07:00
|
|
|
struct _Eio_File_Stat
|
|
|
|
{
|
|
|
|
Eio_File common;
|
|
|
|
|
|
|
|
Eio_Stat_Cb done_cb;
|
|
|
|
|
|
|
|
struct stat buffer;
|
|
|
|
const char *path;
|
|
|
|
};
|
|
|
|
|
* eio: add eio_file_move (completly asynchronous and non
blocking move). It first try a rename, then fallback to
an eio_file_copy + eio_file_unlink.
Small example on how to use it :
#include <Ecore.h>
#include <Eio.h>
static void
_test_done_cb(void *data)
{
printf("move done\n");
ecore_main_loop_quit();
}
static void
_test_error_cb(int error, void *data)
{
fprintf(stderr, "error: [%s]\n", strerror(error));
ecore_main_loop_quit();
}
int
main(int argc, char **argv)
{
Eio_File *cp;
if (argc != 3)
{
fprintf(stderr, "eio_cp source_file destination_file\n");
return -1;
}
ecore_init();
eio_init();
cp = eio_file_move(argv[1], argv[2],
NULL,
_test_done_cb,
_test_error_cb,
NULL);
ecore_main_loop_begin();
eio_shutdown();
ecore_shutdown();
return 0;
}
SVN revision: 52845
2010-09-28 02:05:51 -07:00
|
|
|
struct _Eio_File_Progress
|
* eio: add eio_file_copy (using splice when available and
fallback to mmap/write with huge tlb when not).
That what an eio_cp would look like :
#include <Ecore.h>
#include <Eio.h>
static void
_test_progress_cb(void *data, const Eio_Progress *info)
{
printf("%f (%zi / %zi octets)\n", info->percent, info->current, info->max);
}
static void
_test_done_cb(void *data)
{
printf("copy done\n");
ecore_main_loop_quit();
}
static void
_test_error_cb(int error, void *data)
{
fprintf(stderr, "error: [%s]\n", strerror(error));
ecore_main_loop_quit();
}
int
main(int argc, char **argv)
{
Eio_File *cp;
if (argc != 3)
{
fprintf(stderr, "eio_cp source_file destination_file\n");
return -1;
}
ecore_init();
eio_init();
cp = eio_file_copy(argv[1], argv[2],
_test_progress_cb,
_test_done_cb,
_test_error_cb,
NULL);
ecore_main_loop_begin();
eio_shutdown();
ecore_shutdown();
return 0;
}
SVN revision: 52787
2010-09-26 14:47:48 -07:00
|
|
|
{
|
|
|
|
Eio_File common;
|
|
|
|
|
|
|
|
Eio_Progress_Cb progress_cb;
|
|
|
|
|
|
|
|
const char *source;
|
|
|
|
const char *dest;
|
2010-10-05 07:55:47 -07:00
|
|
|
|
|
|
|
Eio_File_Op op;
|
* eio: add eio_file_copy (using splice when available and
fallback to mmap/write with huge tlb when not).
That what an eio_cp would look like :
#include <Ecore.h>
#include <Eio.h>
static void
_test_progress_cb(void *data, const Eio_Progress *info)
{
printf("%f (%zi / %zi octets)\n", info->percent, info->current, info->max);
}
static void
_test_done_cb(void *data)
{
printf("copy done\n");
ecore_main_loop_quit();
}
static void
_test_error_cb(int error, void *data)
{
fprintf(stderr, "error: [%s]\n", strerror(error));
ecore_main_loop_quit();
}
int
main(int argc, char **argv)
{
Eio_File *cp;
if (argc != 3)
{
fprintf(stderr, "eio_cp source_file destination_file\n");
return -1;
}
ecore_init();
eio_init();
cp = eio_file_copy(argv[1], argv[2],
_test_progress_cb,
_test_done_cb,
_test_error_cb,
NULL);
ecore_main_loop_begin();
eio_shutdown();
ecore_shutdown();
return 0;
}
SVN revision: 52787
2010-09-26 14:47:48 -07:00
|
|
|
};
|
|
|
|
|
* eio: add eio_file_move (completly asynchronous and non
blocking move). It first try a rename, then fallback to
an eio_file_copy + eio_file_unlink.
Small example on how to use it :
#include <Ecore.h>
#include <Eio.h>
static void
_test_done_cb(void *data)
{
printf("move done\n");
ecore_main_loop_quit();
}
static void
_test_error_cb(int error, void *data)
{
fprintf(stderr, "error: [%s]\n", strerror(error));
ecore_main_loop_quit();
}
int
main(int argc, char **argv)
{
Eio_File *cp;
if (argc != 3)
{
fprintf(stderr, "eio_cp source_file destination_file\n");
return -1;
}
ecore_init();
eio_init();
cp = eio_file_move(argv[1], argv[2],
NULL,
_test_done_cb,
_test_error_cb,
NULL);
ecore_main_loop_begin();
eio_shutdown();
ecore_shutdown();
return 0;
}
SVN revision: 52845
2010-09-28 02:05:51 -07:00
|
|
|
struct _Eio_File_Move
|
|
|
|
{
|
|
|
|
Eio_File_Progress progress;
|
|
|
|
|
|
|
|
Eio_File *copy;
|
|
|
|
};
|
|
|
|
|
2010-10-05 04:44:03 -07:00
|
|
|
struct _Eio_Dir_Copy
|
|
|
|
{
|
|
|
|
Eio_File_Progress progress;
|
|
|
|
|
|
|
|
Eina_List *files;
|
|
|
|
Eina_List *dirs;
|
|
|
|
};
|
|
|
|
|
2010-10-20 09:42:45 -07:00
|
|
|
struct _Eio_File_Chown
|
|
|
|
{
|
|
|
|
Eio_File common;
|
|
|
|
|
|
|
|
const char *path;
|
|
|
|
const char *user;
|
|
|
|
const char *group;
|
|
|
|
};
|
|
|
|
|
2010-09-07 07:43:51 -07:00
|
|
|
/* Be aware that ecore_thread_run could call cancel_cb if something goes wrong. */
|
2010-09-06 09:37:43 -07:00
|
|
|
Eina_Bool eio_file_set(Eio_File *common,
|
|
|
|
Eio_Done_Cb done_cb,
|
2010-09-07 07:43:51 -07:00
|
|
|
Eio_Error_Cb error_cb,
|
2010-09-06 09:37:43 -07:00
|
|
|
const void *data,
|
2010-10-13 10:46:02 -07:00
|
|
|
Ecore_Thread_Heavy_Cb job_cb,
|
2010-09-06 09:37:43 -07:00
|
|
|
Ecore_Cb end_cb,
|
|
|
|
Ecore_Cb cancel_cb);
|
|
|
|
|
2010-09-07 07:43:51 -07:00
|
|
|
/* Be aware that ecore_thread_run could call cancel_cb if something goes wrong. */
|
2010-09-06 09:37:43 -07:00
|
|
|
Eina_Bool eio_long_file_set(Eio_File *common,
|
|
|
|
Eio_Done_Cb done_cb,
|
2010-09-07 07:43:51 -07:00
|
|
|
Eio_Error_Cb error_cb,
|
2010-09-06 09:37:43 -07:00
|
|
|
const void *data,
|
|
|
|
Ecore_Thread_Heavy_Cb heavy_cb,
|
|
|
|
Ecore_Thread_Notify_Cb notify_cb,
|
|
|
|
Ecore_Cb end_cb,
|
|
|
|
Ecore_Cb cancel_cb);
|
|
|
|
|
2010-09-06 08:27:10 -07:00
|
|
|
void eio_file_error(Eio_File *common);
|
2010-10-13 10:46:02 -07:00
|
|
|
void eio_file_thread_error(Eio_File *common, Ecore_Thread *thread);
|
2010-09-06 08:27:10 -07:00
|
|
|
|
2010-10-11 05:40:20 -07:00
|
|
|
Eina_File_Direct_Info *eio_direct_info_malloc(void);
|
|
|
|
void eio_direct_info_free(Eina_File_Direct_Info *data);
|
|
|
|
|
2010-10-05 04:44:03 -07:00
|
|
|
Eio_Progress *eio_progress_malloc(void);
|
|
|
|
void eio_progress_free(Eio_Progress *progress);
|
2010-10-11 05:40:20 -07:00
|
|
|
|
2010-10-05 05:56:07 -07:00
|
|
|
void eio_progress_send(Ecore_Thread *thread, Eio_File_Progress *op,
|
|
|
|
off_t current, off_t max);
|
2010-10-05 08:32:24 -07:00
|
|
|
void eio_progress_cb(Eio_Progress *progress, Eio_File_Progress *op);
|
|
|
|
|
2010-10-05 07:55:47 -07:00
|
|
|
Eina_Bool eio_file_copy_do(Ecore_Thread *thread, Eio_File_Progress *copy);
|
2010-10-05 04:44:03 -07:00
|
|
|
|
2010-09-01 01:23:15 -07:00
|
|
|
#endif
|