2010-09-01 01:23:15 -07:00
|
|
|
#ifndef EIO_PRIVATE_H_
|
|
|
|
#define EIO_PRIVATE_H_
|
|
|
|
|
2012-11-23 13:55:46 -08:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2012-11-23 14:09:43 -08:00
|
|
|
#ifdef STDC_HEADERS
|
|
|
|
# include <stdlib.h>
|
|
|
|
# include <stddef.h>
|
|
|
|
#else
|
|
|
|
# ifdef HAVE_STDLIB_H
|
|
|
|
# include <stdlib.h>
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
2012-03-25 12:15:44 -07:00
|
|
|
#include <sys/types.h>
|
|
|
|
#ifdef HAVE_DIRENT_H
|
|
|
|
# include <dirent.h>
|
|
|
|
# define NAMLEN(dirent) strlen ((dirent)->d_name)
|
|
|
|
#else
|
|
|
|
# define dirent direct
|
|
|
|
# define NAMLEN(dirent) ((dirent)->d_namlen)
|
|
|
|
# ifdef HAVE_SYS_NDIR_H
|
|
|
|
# include <sys/ndir.h>
|
|
|
|
# endif
|
|
|
|
# ifdef HAVE_SYS_DIR_H
|
|
|
|
# include <sys/dir.h>
|
|
|
|
# endif
|
|
|
|
# ifdef HAVE_NDIR_H
|
|
|
|
# include <ndir.h>
|
|
|
|
# endif
|
2010-10-12 17:26:12 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#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 <sys/mman.h>
|
|
|
|
#include <fcntl.h>
|
2012-03-25 12:15:44 -07:00
|
|
|
|
|
|
|
#ifdef HAVE_FEATURES_H
|
|
|
|
# include <features.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
# include <unistd.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_LIBGEN_H
|
|
|
|
# include <libgen.h>
|
|
|
|
#endif
|
2010-10-21 10:51:21 -07:00
|
|
|
|
2012-03-30 23:30:08 -07:00
|
|
|
#ifdef HAVE_EVIL
|
|
|
|
# include <Evil.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"
|
|
|
|
|
2012-03-30 23:30:08 -07:00
|
|
|
#ifdef _WIN32
|
|
|
|
typedef struct __stat64 _eio_stat_t;
|
|
|
|
#define _eio_stat(p, b) _stat64(p, b)
|
|
|
|
#define _eio_lstat(p, b) _stat64(p, b)
|
|
|
|
#else
|
|
|
|
typedef struct stat _eio_stat_t;
|
|
|
|
#define _eio_stat(p, b) stat(p, b)
|
|
|
|
#define _eio_lstat(p, b) lstat(p, b)
|
2012-12-31 07:16:49 -08:00
|
|
|
|
|
|
|
# include <grp.h>
|
|
|
|
# include <pwd.h>
|
2012-03-30 23:30:08 -07:00
|
|
|
#endif
|
|
|
|
|
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
|
|
|
|
|
2011-09-05 13:29:01 -07:00
|
|
|
#define EIO_PACKED_TIME 0.003
|
2011-08-29 04:20:27 -07:00
|
|
|
|
2012-08-27 23:28:56 -07:00
|
|
|
extern int _eio_log_dom_global;
|
|
|
|
|
|
|
|
#ifdef EIO_DEFAULT_LOG_COLOR
|
|
|
|
# undef EIO_DEFAULT_LOG_COLOR
|
|
|
|
#endif /* ifdef EIO_DEFAULT_LOG_COLOR */
|
|
|
|
#define EIO_DEFAULT_LOG_COLOR EINA_COLOR_CYAN
|
|
|
|
#ifdef ERR
|
|
|
|
# undef ERR
|
|
|
|
#endif /* ifdef ERR */
|
|
|
|
#define ERR(...) EINA_LOG_DOM_ERR(_eio_log_dom_global, __VA_ARGS__)
|
|
|
|
#ifdef DBG
|
|
|
|
# undef DBG
|
|
|
|
#endif /* ifdef DBG */
|
|
|
|
#define DBG(...) EINA_LOG_DOM_DBG(_eio_log_dom_global, __VA_ARGS__)
|
|
|
|
#ifdef INF
|
|
|
|
# undef INF
|
|
|
|
#endif /* ifdef INF */
|
|
|
|
#define INF(...) EINA_LOG_DOM_INFO(_eio_log_dom_global, __VA_ARGS__)
|
|
|
|
#ifdef WRN
|
|
|
|
# undef WRN
|
|
|
|
#endif /* ifdef WRN */
|
|
|
|
#define WRN(...) EINA_LOG_DOM_WARN(_eio_log_dom_global, __VA_ARGS__)
|
|
|
|
#ifdef CRIT
|
|
|
|
# undef CRIT
|
|
|
|
#endif /* ifdef CRIT */
|
|
|
|
#define CRIT(...) EINA_LOG_DOM_CRIT(_eio_log_dom_global, __VA_ARGS__)
|
|
|
|
|
2012-02-21 13:01:22 -08:00
|
|
|
typedef struct _Eio_Eet_Open Eio_Eet_Open;
|
|
|
|
typedef struct _Eio_Eet_Simple Eio_Eet_Simple;
|
|
|
|
typedef struct _Eio_Eet_Write Eio_Eet_Write;
|
|
|
|
typedef struct _Eio_Eet_Read Eio_Eet_Read;
|
|
|
|
typedef struct _Eio_Eet_Image_Write Eio_Eet_Image_Write;
|
2011-12-20 09:35:41 -08:00
|
|
|
typedef struct _Eio_File_Map Eio_File_Map;
|
|
|
|
typedef struct _Eio_File_Map_Rule Eio_File_Map_Rule;
|
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;
|
2012-02-22 03:51:45 -08:00
|
|
|
typedef struct _Eio_File_Dir_Ls Eio_File_Dir_Ls;
|
2010-09-01 01:23:15 -07:00
|
|
|
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;
|
2011-04-25 10:04:46 -07:00
|
|
|
typedef struct _Eio_Monitor_Backend Eio_Monitor_Backend;
|
2010-09-01 01:23:15 -07:00
|
|
|
|
2011-06-29 10:28:55 -07:00
|
|
|
typedef struct _Eio_File_Xattr Eio_File_Xattr;
|
|
|
|
|
2010-10-05 04:44:03 -07:00
|
|
|
typedef struct _Eio_Dir_Copy Eio_Dir_Copy;
|
|
|
|
|
2011-06-07 09:30:10 -07:00
|
|
|
typedef struct _Eio_File_Direct_Info Eio_File_Direct_Info;
|
|
|
|
typedef struct _Eio_File_Char Eio_File_Char;
|
|
|
|
|
|
|
|
typedef struct _Eio_File_Associate Eio_File_Associate;
|
|
|
|
|
|
|
|
struct _Eio_File_Associate
|
|
|
|
{
|
|
|
|
void *data;
|
|
|
|
|
|
|
|
Eina_Free_Cb free_cb;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _Eio_File_Direct_Info
|
|
|
|
{
|
|
|
|
Eina_File_Direct_Info info;
|
|
|
|
|
|
|
|
Eina_Hash *associated;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _Eio_File_Char
|
|
|
|
{
|
|
|
|
const char *filename;
|
|
|
|
|
|
|
|
Eina_Hash *associated;
|
|
|
|
};
|
|
|
|
|
2010-09-01 01:23:15 -07:00
|
|
|
struct _Eio_File
|
|
|
|
{
|
|
|
|
Ecore_Thread *thread;
|
|
|
|
const void *data;
|
2011-05-24 03:41:37 -07:00
|
|
|
void *container;
|
2010-09-01 01:23:15 -07:00
|
|
|
|
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;
|
2011-06-07 09:30:10 -07:00
|
|
|
|
|
|
|
struct {
|
|
|
|
Eina_Hash *associated;
|
|
|
|
} worker, main;
|
2010-09-01 01:23:15 -07:00
|
|
|
};
|
|
|
|
|
2012-02-21 13:01:22 -08:00
|
|
|
struct _Eio_Eet_Simple
|
|
|
|
{
|
|
|
|
Eio_File common;
|
|
|
|
|
|
|
|
Eet_File *ef;
|
|
|
|
Eio_Eet_Error_Cb error_cb;
|
|
|
|
Eet_Error error;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _Eio_Eet_Write
|
|
|
|
{
|
|
|
|
Eio_File common;
|
|
|
|
|
|
|
|
Eet_File *ef;
|
|
|
|
Eet_Data_Descriptor *edd;
|
|
|
|
const char *name;
|
|
|
|
const char *cipher_key;
|
|
|
|
void *write_data;
|
|
|
|
int compress;
|
|
|
|
int size;
|
|
|
|
|
|
|
|
int result;
|
|
|
|
Eio_Done_Int_Cb done_cb;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _Eio_Eet_Read
|
|
|
|
{
|
|
|
|
Eio_File common;
|
|
|
|
|
|
|
|
Eet_File *ef;
|
|
|
|
Eet_Data_Descriptor *edd;
|
|
|
|
const char *name;
|
|
|
|
const char *cipher_key;
|
|
|
|
|
|
|
|
int size;
|
|
|
|
|
|
|
|
void *result;
|
|
|
|
union {
|
|
|
|
Eio_Done_ERead_Cb eread;
|
|
|
|
Eio_Done_Data_Cb data;
|
|
|
|
Eio_Done_Read_Cb read;
|
|
|
|
} done_cb;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _Eio_Eet_Image_Write
|
|
|
|
{
|
|
|
|
Eio_File common;
|
|
|
|
|
|
|
|
Eet_File *ef;
|
|
|
|
const char *name;
|
|
|
|
const char *cipher_key;
|
|
|
|
void *write_data;
|
|
|
|
|
|
|
|
unsigned int w;
|
|
|
|
unsigned int h;
|
|
|
|
int alpha;
|
|
|
|
int compress;
|
|
|
|
int quality;
|
|
|
|
int lossy;
|
|
|
|
|
|
|
|
int result;
|
|
|
|
Eio_Done_Int_Cb done_cb;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _Eio_Eet_Open
|
|
|
|
{
|
|
|
|
Eio_File common;
|
|
|
|
|
|
|
|
Eio_Eet_Open_Cb eet_cb;
|
|
|
|
const char *filename;
|
|
|
|
Eet_File_Mode mode;
|
|
|
|
|
|
|
|
Eet_File *result;
|
|
|
|
};
|
|
|
|
|
2011-12-20 09:35:41 -08:00
|
|
|
struct _Eio_File_Map
|
|
|
|
{
|
|
|
|
Eio_File common;
|
|
|
|
|
|
|
|
Eio_Open_Cb open_cb;
|
|
|
|
const char *name;
|
|
|
|
Eina_Bool shared;
|
|
|
|
|
|
|
|
Eina_File *result;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _Eio_File_Map_Rule
|
|
|
|
{
|
|
|
|
Eio_File common;
|
|
|
|
Eio_Filter_Map_Cb filter_cb;
|
|
|
|
Eio_Map_Cb map_cb;
|
2011-12-29 02:46:56 -08:00
|
|
|
|
2011-12-20 09:35:41 -08:00
|
|
|
Eina_File_Populate rule;
|
2011-12-29 02:46:56 -08:00
|
|
|
Eina_File *file;
|
2011-12-20 09:35:41 -08:00
|
|
|
|
|
|
|
unsigned long int offset;
|
|
|
|
unsigned long int length;
|
|
|
|
|
|
|
|
void *result;
|
|
|
|
};
|
|
|
|
|
2010-09-01 01:23:15 -07:00
|
|
|
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;
|
2011-08-29 04:20:27 -07:00
|
|
|
|
|
|
|
Eina_List *pack;
|
|
|
|
double start;
|
2010-09-01 01:23:15 -07:00
|
|
|
};
|
|
|
|
|
2012-02-22 03:51:45 -08:00
|
|
|
struct _Eio_File_Dir_Ls
|
|
|
|
{
|
|
|
|
Eio_File_Ls ls;
|
|
|
|
|
|
|
|
Eio_Filter_Dir_Cb filter_cb;
|
|
|
|
Eio_Main_Direct_Cb main_cb;
|
|
|
|
|
|
|
|
Eina_List *pack;
|
|
|
|
double start;
|
|
|
|
};
|
|
|
|
|
2010-09-01 01:23:15 -07:00
|
|
|
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;
|
|
|
|
|
2012-02-23 03:46:51 -08:00
|
|
|
Eina_Stat buffer;
|
2010-09-06 08:27:10 -07:00
|
|
|
const char *path;
|
|
|
|
};
|
|
|
|
|
2011-09-16 07:18:08 -07:00
|
|
|
typedef enum {
|
|
|
|
EIO_XATTR_DATA,
|
|
|
|
EIO_XATTR_STRING,
|
|
|
|
EIO_XATTR_DOUBLE,
|
|
|
|
EIO_XATTR_INT
|
|
|
|
} Eio_File_Xattr_Op;
|
|
|
|
|
2011-06-29 10:28:55 -07:00
|
|
|
struct _Eio_File_Xattr
|
|
|
|
{
|
|
|
|
Eio_File common;
|
|
|
|
|
|
|
|
const char *path;
|
|
|
|
const char *attribute;
|
2011-09-16 04:14:57 -07:00
|
|
|
Eina_Xattr_Flags flags;
|
2011-06-29 10:28:55 -07:00
|
|
|
|
2011-09-16 07:18:08 -07:00
|
|
|
Eio_File_Xattr_Op op;
|
|
|
|
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
Eio_Done_Data_Cb done_cb;
|
|
|
|
|
|
|
|
char *xattr_data;
|
|
|
|
ssize_t xattr_size;
|
|
|
|
} xdata;
|
|
|
|
struct {
|
|
|
|
Eio_Done_String_Cb done_cb;
|
|
|
|
|
|
|
|
char *xattr_string;
|
|
|
|
} xstring;
|
|
|
|
struct {
|
|
|
|
Eio_Done_Double_Cb done_cb;
|
|
|
|
|
|
|
|
double xattr_double;
|
|
|
|
} xdouble;
|
|
|
|
struct {
|
|
|
|
Eio_Done_Int_Cb done_cb;
|
|
|
|
|
|
|
|
int xattr_int;
|
|
|
|
} xint;
|
|
|
|
} todo;
|
2011-09-19 05:47:02 -07:00
|
|
|
|
|
|
|
Eina_Bool set : 1;
|
2011-06-29 10:28:55 -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_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;
|
2011-03-09 08:21:11 -08:00
|
|
|
Eio_Filter_Direct_Cb filter_cb;
|
|
|
|
|
2010-10-05 04:44:03 -07:00
|
|
|
Eina_List *files;
|
|
|
|
Eina_List *dirs;
|
2010-11-03 05:35:21 -07:00
|
|
|
Eina_List *links;
|
2010-10-05 04:44:03 -07:00
|
|
|
};
|
|
|
|
|
2010-10-20 09:42:45 -07:00
|
|
|
struct _Eio_File_Chown
|
|
|
|
{
|
|
|
|
Eio_File common;
|
|
|
|
|
|
|
|
const char *path;
|
|
|
|
const char *user;
|
|
|
|
const char *group;
|
|
|
|
};
|
|
|
|
|
2011-04-25 10:04:46 -07:00
|
|
|
struct _Eio_Monitor
|
|
|
|
{
|
|
|
|
Eio_Monitor_Backend *backend;
|
|
|
|
Eio_File *exist;
|
|
|
|
|
|
|
|
const char *path;
|
|
|
|
|
2011-04-29 09:24:14 -07:00
|
|
|
EINA_REFCOUNT;
|
2011-04-25 10:04:46 -07:00
|
|
|
int error;
|
|
|
|
|
2012-05-08 23:54:09 -07:00
|
|
|
time_t mtime;
|
|
|
|
|
2011-04-25 10:04:46 -07:00
|
|
|
Eina_Bool fallback : 1;
|
2011-04-27 03:27:07 -07:00
|
|
|
Eina_Bool rename : 1;
|
2012-05-08 23:54:09 -07:00
|
|
|
Eina_Bool delete_me : 1;
|
2011-04-25 10:04:46 -07:00
|
|
|
};
|
|
|
|
|
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-11-12 05:28:19 -08:00
|
|
|
Ecore_Thread_Cb job_cb,
|
|
|
|
Ecore_Thread_Cb end_cb,
|
|
|
|
Ecore_Thread_Cb cancel_cb);
|
2010-09-06 09:37:43 -07:00
|
|
|
|
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,
|
2010-11-12 05:28:19 -08:00
|
|
|
Ecore_Thread_Cb heavy_cb,
|
2010-09-06 09:37:43 -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-09-06 09:37:43 -07:00
|
|
|
|
2012-08-30 01:52:15 -07:00
|
|
|
void eio_file_free(Eio_File *common);
|
|
|
|
void eio_async_free(Eio_File_Ls *async);
|
|
|
|
|
2011-05-24 03:41:37 -07:00
|
|
|
void eio_file_container_set(Eio_File *common, void *container);
|
|
|
|
|
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
|
|
|
|
2011-06-07 09:30:10 -07:00
|
|
|
Eio_File_Direct_Info *eio_direct_info_malloc(void);
|
|
|
|
void eio_direct_info_free(Eio_File_Direct_Info *data);
|
|
|
|
|
|
|
|
Eio_File_Char *eio_char_malloc(void);
|
|
|
|
void eio_char_free(Eio_File_Char *data);
|
|
|
|
|
2011-06-23 06:29:45 -07:00
|
|
|
Eio_File_Associate *eio_associate_malloc(const void *data, Eina_Free_Cb free_cb);
|
2011-06-07 09:30:10 -07:00
|
|
|
void eio_associate_free(void *data);
|
2010-10-11 05:40:20 -07:00
|
|
|
|
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,
|
2011-03-09 06:53:55 -08:00
|
|
|
long long current, long long 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
|
|
|
|
2011-04-25 10:04:46 -07:00
|
|
|
void eio_monitor_init(void);
|
|
|
|
void eio_monitor_backend_init(void);
|
|
|
|
void eio_monitor_fallback_init(void);
|
|
|
|
|
|
|
|
void eio_monitor_shutdown(void);
|
|
|
|
void eio_monitor_backend_shutdown(void);
|
|
|
|
void eio_monitor_fallback_shutdown(void);
|
|
|
|
void eio_monitor_backend_add(Eio_Monitor *monitor);
|
|
|
|
void eio_monitor_fallback_add(Eio_Monitor *monitor);
|
|
|
|
|
|
|
|
void eio_monitor_backend_del(Eio_Monitor *monitor);
|
|
|
|
void eio_monitor_fallback_del(Eio_Monitor *monitor);
|
|
|
|
|
2011-04-27 03:27:07 -07:00
|
|
|
void _eio_monitor_send(Eio_Monitor *monitor, const char *filename, int event_code);
|
|
|
|
void _eio_monitor_rename(Eio_Monitor *monitor, const char *newpath);
|
|
|
|
|
2011-05-03 03:36:51 -07:00
|
|
|
void eio_async_end(void *data, Ecore_Thread *thread);
|
|
|
|
void eio_async_error(void *data, Ecore_Thread *thread);
|
|
|
|
|
2010-09-01 01:23:15 -07:00
|
|
|
#endif
|