forked from enlightenment/efl
eio: use the newly introduced Eina_Stat.
SVN revision: 68316
This commit is contained in:
parent
b693dd6035
commit
4a65416c6a
|
@ -374,13 +374,13 @@
|
||||||
* static Eina_Bool
|
* static Eina_Bool
|
||||||
* _test_filter_cb(void *data, Eio_File *handler, Eina_File_Direct_Info *info)
|
* _test_filter_cb(void *data, Eio_File *handler, Eina_File_Direct_Info *info)
|
||||||
* {
|
* {
|
||||||
* struct stat *buffer;
|
* Eina_Stat *buffer;
|
||||||
* Eina_Bool isdir;
|
* Eina_Bool isdir;
|
||||||
*
|
*
|
||||||
* isdir = info->type == EINA_FILE_DIR;
|
* isdir = info->type == EINA_FILE_DIR;
|
||||||
*
|
*
|
||||||
* buffer = malloc(sizeof (struct stat));
|
* buffer = malloc(sizeof (Eina_Stat));
|
||||||
* if (eina_file_stat(eio_file_container_get(handler), info, buffer))
|
* if (eina_file_statat(eio_file_container_get(handler), info, buffer))
|
||||||
* {
|
* {
|
||||||
* free(buffer);
|
* free(buffer);
|
||||||
* return EINA_FALSE;
|
* return EINA_FALSE;
|
||||||
|
@ -388,9 +388,10 @@
|
||||||
*
|
*
|
||||||
* if (!isdir && info->type == EINA_FILE_DIR)
|
* if (!isdir && info->type == EINA_FILE_DIR)
|
||||||
* {
|
* {
|
||||||
* if (lstat(info->path, buffer) == 0)
|
* struct stat st;
|
||||||
|
* if (lstat(info->path, &st) == 0)
|
||||||
* {
|
* {
|
||||||
* if (S_ISLNK(buffer->st_mode))
|
* if (S_ISLNK(st.st_mode))
|
||||||
* info->type = EINA_FILE_LNK;
|
* info->type = EINA_FILE_LNK;
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
|
|
|
@ -116,7 +116,7 @@ typedef Eina_Bool (*Eio_Filter_Direct_Cb)(void *data, Eio_File *handler, const E
|
||||||
typedef Eina_Bool (*Eio_Filter_Dir_Cb)(void *data, Eio_File *handler, Eina_File_Direct_Info *info);
|
typedef Eina_Bool (*Eio_Filter_Dir_Cb)(void *data, Eio_File *handler, Eina_File_Direct_Info *info);
|
||||||
typedef void (*Eio_Main_Direct_Cb)(void *data, Eio_File *handler, const Eina_File_Direct_Info *info);
|
typedef void (*Eio_Main_Direct_Cb)(void *data, Eio_File *handler, const Eina_File_Direct_Info *info);
|
||||||
|
|
||||||
typedef void (*Eio_Stat_Cb)(void *data, Eio_File *handler, const struct stat *stat);
|
typedef void (*Eio_Stat_Cb)(void *data, Eio_File *handler, const Eina_Stat *stat);
|
||||||
typedef void (*Eio_Progress_Cb)(void *data, Eio_File *handler, const Eio_Progress *info);
|
typedef void (*Eio_Progress_Cb)(void *data, Eio_File *handler, const Eio_Progress *info);
|
||||||
|
|
||||||
typedef void (*Eio_Eet_Open_Cb)(void *data, Eio_File *handler, Eet_File *file);
|
typedef void (*Eio_Eet_Open_Cb)(void *data, Eio_File *handler, Eet_File *file);
|
||||||
|
@ -715,44 +715,44 @@ EAPI Eina_Bool eio_file_associate_direct_add(Eio_File *ls,
|
||||||
EAPI void *eio_file_associate_find(Eio_File *ls, const char *key);
|
EAPI void *eio_file_associate_find(Eio_File *ls, const char *key);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief get access time from a struct stat
|
* @brief get access time from a Eina_Stat
|
||||||
* @param stat the structure to get the atime from
|
* @param stat the structure to get the atime from
|
||||||
* @return the last accessed time
|
* @return the last accessed time
|
||||||
*
|
*
|
||||||
* This take care of doing type conversion to match rest of EFL time API.
|
* This take care of doing type conversion to match rest of EFL time API.
|
||||||
* @note some filesystem don't update that information.
|
* @note some filesystem don't update that information.
|
||||||
*/
|
*/
|
||||||
static inline double eio_file_atime(const struct stat *stat);
|
static inline double eio_file_atime(const Eina_Stat *stat);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief get modification time from a struct stat
|
* @brief get modification time from a Eina_Stat
|
||||||
* @param stat the structure to get the mtime from
|
* @param stat the structure to get the mtime from
|
||||||
* @return the last modification time
|
* @return the last modification time
|
||||||
*
|
*
|
||||||
* This take care of doing type conversion to match rest of EFL time API.
|
* This take care of doing type conversion to match rest of EFL time API.
|
||||||
*/
|
*/
|
||||||
static inline double eio_file_mtime(const struct stat *stat);
|
static inline double eio_file_mtime(const Eina_Stat *stat);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief get the size of the file described in struct stat
|
* @brief get the size of the file described in Eina_Stat
|
||||||
* @param stat the structure to get the size from
|
* @param stat the structure to get the size from
|
||||||
* @return the size of the file
|
* @return the size of the file
|
||||||
*/
|
*/
|
||||||
static inline long long eio_file_size(const struct stat *stat);
|
static inline long long eio_file_size(const Eina_Stat *stat);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief tell if the stated path was a directory or not.
|
* @brief tell if the stated path was a directory or not.
|
||||||
* @param stat the structure to get the size from
|
* @param stat the structure to get the size from
|
||||||
* @return EINA_TRUE, if it was.
|
* @return EINA_TRUE, if it was.
|
||||||
*/
|
*/
|
||||||
static inline Eina_Bool eio_file_is_dir(const struct stat *stat);
|
static inline Eina_Bool eio_file_is_dir(const Eina_Stat *stat);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief tell if the stated path was a link or not.
|
* @brief tell if the stated path was a link or not.
|
||||||
* @param stat the structure to get the size from
|
* @param stat the structure to get the size from
|
||||||
* @return EINA_TRUE, if it was.
|
* @return EINA_TRUE, if it was.
|
||||||
*/
|
*/
|
||||||
static inline Eina_Bool eio_file_is_lnk(const struct stat *stat);
|
static inline Eina_Bool eio_file_is_lnk(const Eina_Stat *stat);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
|
|
|
@ -36,10 +36,10 @@
|
||||||
* This function return the st_atime field, last acces time, as double like all EFL time call.
|
* This function return the st_atime field, last acces time, as double like all EFL time call.
|
||||||
*/
|
*/
|
||||||
static inline double
|
static inline double
|
||||||
eio_file_atime(const struct stat *st)
|
eio_file_atime(const Eina_Stat *st)
|
||||||
{
|
{
|
||||||
if (!st) return 0.0;
|
if (!st) return 0.0;
|
||||||
return (double) st->st_atime;
|
return (double) st->atime;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -50,10 +50,10 @@ eio_file_atime(const struct stat *st)
|
||||||
* This function return the st_mtime field, last modification time, as double like all EFL time call.
|
* This function return the st_mtime field, last modification time, as double like all EFL time call.
|
||||||
*/
|
*/
|
||||||
static inline double
|
static inline double
|
||||||
eio_file_mtime(const struct stat *st)
|
eio_file_mtime(const Eina_Stat *st)
|
||||||
{
|
{
|
||||||
if (!st) return 0.0;
|
if (!st) return 0.0;
|
||||||
return (double) st->st_mtime;
|
return (double) st->mtime;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -64,10 +64,10 @@ eio_file_mtime(const struct stat *st)
|
||||||
* This function is just an accessor to st_size and return the file length.
|
* This function is just an accessor to st_size and return the file length.
|
||||||
*/
|
*/
|
||||||
static inline long long
|
static inline long long
|
||||||
eio_file_size(const struct stat *st)
|
eio_file_size(const Eina_Stat *st)
|
||||||
{
|
{
|
||||||
if (!st) return 0;
|
if (!st) return 0;
|
||||||
return st->st_size;
|
return st->size;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -78,10 +78,10 @@ eio_file_size(const struct stat *st)
|
||||||
* This function tell you if the stated path is a directory or not.
|
* This function tell you if the stated path is a directory or not.
|
||||||
*/
|
*/
|
||||||
static inline Eina_Bool
|
static inline Eina_Bool
|
||||||
eio_file_is_dir(const struct stat *st)
|
eio_file_is_dir(const Eina_Stat *st)
|
||||||
{
|
{
|
||||||
if (!st) return EINA_FALSE;
|
if (!st) return EINA_FALSE;
|
||||||
return (S_ISDIR(st->st_mode)) ? EINA_TRUE : EINA_FALSE;
|
return (S_ISDIR(st->mode)) ? EINA_TRUE : EINA_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -92,10 +92,10 @@ eio_file_is_dir(const struct stat *st)
|
||||||
* This function tell you if the stated path is a length or not.
|
* This function tell you if the stated path is a length or not.
|
||||||
*/
|
*/
|
||||||
static inline Eina_Bool
|
static inline Eina_Bool
|
||||||
eio_file_is_lnk(const struct stat *st)
|
eio_file_is_lnk(const Eina_Stat *st)
|
||||||
{
|
{
|
||||||
if (!st) return EINA_FALSE;
|
if (!st) return EINA_FALSE;
|
||||||
return (S_ISLNK(st->st_mode)) ? EINA_TRUE : EINA_FALSE;
|
return (S_ISLNK(st->mode)) ? EINA_TRUE : EINA_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -76,7 +76,7 @@ _eio_monitor_event_cleanup_cb(__UNUSED__ void *user_data, void *func_data)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_eio_monitor_stat_cb(void *data, __UNUSED__ Eio_File *handler, __UNUSED__ const struct stat *st)
|
_eio_monitor_stat_cb(void *data, __UNUSED__ Eio_File *handler, __UNUSED__ const Eina_Stat *st)
|
||||||
{
|
{
|
||||||
Eio_Monitor *monitor = data;
|
Eio_Monitor *monitor = data;
|
||||||
|
|
||||||
|
|
|
@ -275,7 +275,7 @@ struct _Eio_File_Stat
|
||||||
|
|
||||||
Eio_Stat_Cb done_cb;
|
Eio_Stat_Cb done_cb;
|
||||||
|
|
||||||
struct stat buffer;
|
Eina_Stat buffer;
|
||||||
const char *path;
|
const char *path;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -105,9 +105,40 @@ static void
|
||||||
_eio_file_stat(void *data, Ecore_Thread *thread)
|
_eio_file_stat(void *data, Ecore_Thread *thread)
|
||||||
{
|
{
|
||||||
Eio_File_Stat *s = data;
|
Eio_File_Stat *s = data;
|
||||||
|
struct stat buf;
|
||||||
|
|
||||||
if (stat(s->path, &s->buffer) != 0)
|
if (stat(s->path, &buf) != 0)
|
||||||
eio_file_thread_error(&s->common, thread);
|
eio_file_thread_error(&s->common, thread);
|
||||||
|
|
||||||
|
s->buffer.dev = buf.st_dev;
|
||||||
|
s->buffer.ino = buf.st_ino;
|
||||||
|
s->buffer.mode = buf.st_mode;
|
||||||
|
s->buffer.nlink = buf.st_nlink;
|
||||||
|
s->buffer.uid = buf.st_uid;
|
||||||
|
s->buffer.gid = buf.st_gid;
|
||||||
|
s->buffer.rdev = buf.st_rdev;
|
||||||
|
s->buffer.size = buf.st_size;
|
||||||
|
s->buffer.blksize = buf.st_blksize;
|
||||||
|
s->buffer.blocks = buf.st_blocks;
|
||||||
|
s->buffer.atime = buf.st_atime;
|
||||||
|
s->buffer.mtime = buf.st_mtime;
|
||||||
|
s->buffer.ctime = buf.st_ctime;
|
||||||
|
#ifdef _STAT_VER_LINUX
|
||||||
|
# if (defined __USE_MISC && defined st_mtime)
|
||||||
|
s->buffer.atimensec = buf.st_atim.tv_nsec;
|
||||||
|
s->buffer.mtimensec = buf.st_mtim.tv_nsec;
|
||||||
|
s->buffer.ctimensec = buf.st_ctim.tv_nsec;
|
||||||
|
# else
|
||||||
|
s->buffer.atimensec = buf.st_atimensec;
|
||||||
|
s->buffer.mtimensec = buf.st_mtimensec;
|
||||||
|
s->buffer.ctimensec = buf.st_ctimensec;
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
s->buffer.atimensec = 0;
|
||||||
|
s->buffer.mtimensec = 0;
|
||||||
|
s->buffer.ctimensec = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Reference in New Issue