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>
|
2010-10-12 17:26:12 -07:00
|
|
|
|
2013-01-10 12:25:48 -08:00
|
|
|
#include <libgen.h>
|
2010-10-12 17:26:12 -07:00
|
|
|
#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>
|
2013-01-10 12:25:26 -08:00
|
|
|
#include <unistd.h>
|
2010-10-12 17:26:12 -07:00
|
|
|
#include <fcntl.h>
|
2012-03-25 12:15:44 -07:00
|
|
|
|
|
|
|
#ifdef HAVE_FEATURES_H
|
|
|
|
# include <features.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
|
2017-08-14 06:50:03 -07:00
|
|
|
# ifdef _WIN64
|
2012-03-30 23:30:08 -07:00
|
|
|
typedef struct __stat64 _eio_stat_t;
|
2017-08-14 06:50:03 -07:00
|
|
|
# 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) _stat(p, b)
|
|
|
|
# endif
|
2012-03-30 23:30:08 -07:00
|
|
|
#else
|
|
|
|
typedef struct stat _eio_stat_t;
|
2017-08-14 06:50:03 -07:00
|
|
|
# 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
|
|
|
|
|
2020-06-20 06:00:10 -07:00
|
|
|
/* Keeping 8 Eio_File_Progress alive should be enough */
|
2016-12-03 01:01:53 -08:00
|
|
|
#define EIO_PROGRESS_LIMIT 8
|
2010-10-05 04:44:03 -07:00
|
|
|
|
* 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__)
|
2013-12-25 19:22:05 -08:00
|
|
|
#ifdef CRI
|
|
|
|
# undef CRI
|
|
|
|
#endif /* ifdef CRI */
|
|
|
|
#define CRI(...) EINA_LOG_DOM_CRIT(_eio_log_dom_global, __VA_ARGS__)
|
2012-08-27 23:28:56 -07:00
|
|
|
|
2016-07-31 21:39:39 -07:00
|
|
|
typedef void (*Eio_Array_Cb)(void *data, Eio_File *common, Eina_Array *g);
|
|
|
|
|
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
|
|
|
|
{
|
2016-07-31 21:39:39 -07:00
|
|
|
// Do not put anything before info
|
2011-06-07 09:30:10 -07:00
|
|
|
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;
|
2016-07-31 21:37:25 -07:00
|
|
|
|
|
|
|
uint64_t length;
|
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;
|
2014-10-09 12:41:55 -07:00
|
|
|
Eina_Iterator *ls;
|
2016-07-31 21:39:39 -07:00
|
|
|
|
|
|
|
Eina_Bool gather;
|
2010-09-01 01:23:15 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct _Eio_File_Direct_Ls
|
|
|
|
{
|
|
|
|
Eio_File_Ls ls;
|
|
|
|
|
|
|
|
Eio_Filter_Direct_Cb filter_cb;
|
2016-07-31 21:39:39 -07:00
|
|
|
union {
|
|
|
|
Eio_Main_Direct_Cb main_cb;
|
|
|
|
Eio_Array_Cb main_internal_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;
|
2016-07-31 21:39:39 -07:00
|
|
|
union {
|
|
|
|
Eio_Main_Direct_Cb main_cb;
|
|
|
|
Eio_Array_Cb main_internal_cb;
|
|
|
|
};
|
2012-02-22 03:51:45 -08:00
|
|
|
|
|
|
|
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;
|
2016-07-31 21:39:39 -07:00
|
|
|
union {
|
|
|
|
Eio_Main_Cb main_cb;
|
|
|
|
Eio_Array_Cb main_internal_cb;
|
|
|
|
};
|
2010-09-01 01:23:15 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
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);
|
efl_io_model: next try to fix this race condition
what is happening is that a file gets announced through eio_model
listing code, at this point of time, the monitor does not yet know about
the file. If the file now gets deleted between the annoncing and the
learning of the file from the monitor, then the file got an ADD event,
but no DEL event. Which is a bug.
With this commit there is a new API which asks the monitor if the file
already has the knowledge about the files existance, or not. A few
monitors like win32 inotify or cocoa do not have context about the file
directly, if the OS is now having the same bug, then we are again in
trouble, however, we canot do anything about that. In the case of kevent
or poll, this asks the context of the monitor if the file is already
there.
Reviewed-by: Cedric BAIL <cedric.bail@free.fr>
Differential Revision: https://phab.enlightenment.org/D10006
2019-09-18 02:32:08 -07:00
|
|
|
Eina_Bool eio_monitor_context_check(const Eio_Monitor *monitor, const char *path);
|
2011-04-25 10:04:46 -07:00
|
|
|
void eio_monitor_fallback_add(Eio_Monitor *monitor);
|
efl_io_model: next try to fix this race condition
what is happening is that a file gets announced through eio_model
listing code, at this point of time, the monitor does not yet know about
the file. If the file now gets deleted between the annoncing and the
learning of the file from the monitor, then the file got an ADD event,
but no DEL event. Which is a bug.
With this commit there is a new API which asks the monitor if the file
already has the knowledge about the files existance, or not. A few
monitors like win32 inotify or cocoa do not have context about the file
directly, if the OS is now having the same bug, then we are again in
trouble, however, we canot do anything about that. In the case of kevent
or poll, this asks the context of the monitor if the file is already
there.
Reviewed-by: Cedric BAIL <cedric.bail@free.fr>
Differential Revision: https://phab.enlightenment.org/D10006
2019-09-18 02:32:08 -07:00
|
|
|
Eina_Bool eio_monitor_fallback_context_check(const Eio_Monitor *monitor, const char *path);
|
2011-04-25 10:04:46 -07:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2014-03-04 17:41:37 -08:00
|
|
|
Eina_List *eio_pack_send(Ecore_Thread *thread, Eina_List *pack, double *start);
|
|
|
|
|
2015-04-20 05:46:23 -07:00
|
|
|
void *eio_common_alloc(size_t size);
|
|
|
|
void eio_common_free(Eio_File *common);
|
|
|
|
|
2015-01-07 07:43:47 -08:00
|
|
|
void eio_file_register(Eio_File *common);
|
|
|
|
void eio_file_unregister(Eio_File *common);
|
|
|
|
|
2016-07-31 21:39:39 -07:00
|
|
|
Eio_File * _eio_file_ls(const char *dir,
|
|
|
|
Eio_Array_Cb main_internal_cb,
|
|
|
|
Eio_Done_Cb done_cb,
|
|
|
|
Eio_Error_Cb error_cb,
|
|
|
|
const void *data);
|
|
|
|
Eio_File * _eio_file_direct_ls(const char *dir,
|
|
|
|
Eio_Array_Cb main_internal_cb,
|
|
|
|
Eio_Done_Cb done_cb,
|
|
|
|
Eio_Error_Cb error_cb,
|
|
|
|
const void *data);
|
|
|
|
Eio_File * _eio_dir_direct_ls(const char *dir,
|
|
|
|
Eio_Array_Cb main_internal_cb,
|
|
|
|
Eio_Done_Cb done_cb,
|
|
|
|
Eio_Error_Cb error_cb,
|
|
|
|
const void *data);
|
|
|
|
Eio_File * _eio_file_stat_ls(const char *dir,
|
|
|
|
Eio_Array_Cb main_internal_cb,
|
|
|
|
Eio_Done_Cb done_cb,
|
|
|
|
Eio_Error_Cb error_cb,
|
|
|
|
const void *data);
|
|
|
|
Eio_File * _eio_dir_stat_ls(const char *dir,
|
|
|
|
Eio_Array_Cb main_internal_cb,
|
|
|
|
Eio_Done_Cb done_cb,
|
|
|
|
Eio_Error_Cb error_cb,
|
|
|
|
const void *data);
|
2016-09-07 16:20:23 -07:00
|
|
|
Eio_File * _eio_file_xattr(const char *path,
|
|
|
|
Eio_Array_Cb main_internal_cb,
|
|
|
|
Eio_Done_Cb done_cb,
|
|
|
|
Eio_Error_Cb error_cb,
|
|
|
|
const void *data);
|
2016-07-31 21:39:39 -07:00
|
|
|
|
|
|
|
// Sharing notifier between recursive and non recursive code.
|
|
|
|
void _eio_string_notify(void *data, Ecore_Thread *thread EINA_UNUSED, void *msg_data);
|
|
|
|
void _eio_direct_notify(void *data, Ecore_Thread *thread EINA_UNUSED, void *msg_data);
|
|
|
|
|
2019-01-04 16:01:40 -08:00
|
|
|
static inline Eina_Value
|
|
|
|
_efl_io_manager_future_cancel(Eo *o EINA_UNUSED, void *data, Eina_Error error)
|
2017-12-20 16:23:18 -08:00
|
|
|
{
|
2019-01-04 16:01:40 -08:00
|
|
|
if (error == ECANCELED) eio_file_cancel(data);
|
|
|
|
|
|
|
|
return eina_value_error_init(error);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline Eina_Future *
|
|
|
|
_efl_io_manager_future(const Eo *o, Eina_Future *f, Eio_File *h)
|
|
|
|
{
|
|
|
|
return efl_future_then(o, f,
|
|
|
|
.error = _efl_io_manager_future_cancel,
|
|
|
|
.data = h);
|
2017-12-20 16:23:18 -08:00
|
|
|
}
|
|
|
|
|
2017-12-19 16:03:20 -08:00
|
|
|
EINA_VALUE_STRUCT_DESC_DEFINE(_eina_stat_desc,
|
|
|
|
NULL,
|
|
|
|
sizeof (Eina_Stat),
|
|
|
|
EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_ULONG, Eina_Stat, dev),
|
|
|
|
EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_ULONG, Eina_Stat, ino),
|
|
|
|
EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_UINT, Eina_Stat, mode),
|
|
|
|
EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_UINT, Eina_Stat, nlink),
|
|
|
|
EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_UINT, Eina_Stat, uid),
|
|
|
|
EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_UINT, Eina_Stat, gid),
|
|
|
|
EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_ULONG, Eina_Stat, rdev),
|
|
|
|
EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_ULONG, Eina_Stat, size),
|
|
|
|
EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_ULONG, Eina_Stat, blksize),
|
|
|
|
EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_ULONG, Eina_Stat, blocks),
|
|
|
|
EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_TIMESTAMP, Eina_Stat, atime),
|
|
|
|
EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_ULONG, Eina_Stat, atimensec),
|
|
|
|
EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_TIMESTAMP, Eina_Stat, mtime),
|
|
|
|
EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_ULONG, Eina_Stat, mtimensec),
|
|
|
|
EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_TIMESTAMP, Eina_Stat, ctime),
|
|
|
|
EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_ULONG, Eina_Stat, ctimensec));
|
2016-07-31 21:39:39 -07:00
|
|
|
|
2010-09-01 01:23:15 -07:00
|
|
|
#endif
|