forked from enlightenment/efl
parent
39f6f85798
commit
6ecdda5121
|
@ -945,6 +945,13 @@ eina_file_open(const char *path, Eina_Bool shared)
|
||||||
n->global_refcount = 0;
|
n->global_refcount = 0;
|
||||||
n->length = file_stat.st_size;
|
n->length = file_stat.st_size;
|
||||||
n->mtime = file_stat.st_mtime;
|
n->mtime = file_stat.st_mtime;
|
||||||
|
#ifdef _STAT_VER_LINUX
|
||||||
|
# if (defined __USE_MISC && defined st_mtime)
|
||||||
|
n->mtime_nsec = (unsigned long int)file_stat.st_mtim.tv_nsec;
|
||||||
|
# else
|
||||||
|
n->mtime_nsec = (unsigned long int)file_stat.st_mtimensec;
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
n->inode = file_stat.st_ino;
|
n->inode = file_stat.st_ino;
|
||||||
n->refcount = 0;
|
n->refcount = 0;
|
||||||
n->fd = fd;
|
n->fd = fd;
|
||||||
|
|
|
@ -100,12 +100,12 @@ _eina_xattr_ls_iterator_free(Eina_Xattr_Iterator *it)
|
||||||
EAPI Eina_Iterator *
|
EAPI Eina_Iterator *
|
||||||
eina_xattr_ls(const char *file)
|
eina_xattr_ls(const char *file)
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_XATTR
|
||||||
Eina_Xattr_Iterator *it;
|
Eina_Xattr_Iterator *it;
|
||||||
ssize_t length;
|
ssize_t length;
|
||||||
|
|
||||||
EINA_SAFETY_ON_NULL_RETURN_VAL(file, NULL);
|
EINA_SAFETY_ON_NULL_RETURN_VAL(file, NULL);
|
||||||
|
|
||||||
#ifdef HAVE_XATTR
|
|
||||||
length = listxattr(file, NULL, 0);
|
length = listxattr(file, NULL, 0);
|
||||||
if (length <= 0) return NULL;
|
if (length <= 0) return NULL;
|
||||||
|
|
||||||
|
@ -129,12 +129,14 @@ eina_xattr_ls(const char *file)
|
||||||
return &it->iterator;
|
return &it->iterator;
|
||||||
#else
|
#else
|
||||||
return NULL;
|
return NULL;
|
||||||
|
(void)file;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI void *
|
EAPI void *
|
||||||
eina_xattr_get(const char *file, const char *attribute, ssize_t *size)
|
eina_xattr_get(const char *file, const char *attribute, ssize_t *size)
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_XATTR
|
||||||
void *ret = NULL;
|
void *ret = NULL;
|
||||||
ssize_t tmp;
|
ssize_t tmp;
|
||||||
|
|
||||||
|
@ -142,7 +144,6 @@ eina_xattr_get(const char *file, const char *attribute, ssize_t *size)
|
||||||
EINA_SAFETY_ON_NULL_RETURN_VAL(attribute, NULL);
|
EINA_SAFETY_ON_NULL_RETURN_VAL(attribute, NULL);
|
||||||
EINA_SAFETY_ON_TRUE_RETURN_VAL(!size, NULL);
|
EINA_SAFETY_ON_TRUE_RETURN_VAL(!size, NULL);
|
||||||
|
|
||||||
#ifdef HAVE_XATTR
|
|
||||||
*size = getxattr(file, attribute, NULL, 0);
|
*size = getxattr(file, attribute, NULL, 0);
|
||||||
/* Size should be less than 2MB (already huge in my opinion) */
|
/* Size should be less than 2MB (already huge in my opinion) */
|
||||||
if (!(*size > 0 && *size < 2 * 1024 * 1024))
|
if (!(*size > 0 && *size < 2 * 1024 * 1024))
|
||||||
|
@ -159,14 +160,21 @@ eina_xattr_get(const char *file, const char *attribute, ssize_t *size)
|
||||||
|
|
||||||
on_error:
|
on_error:
|
||||||
free(ret);
|
free(ret);
|
||||||
#endif
|
|
||||||
*size = 0;
|
*size = 0;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
#else
|
||||||
|
EINA_SAFETY_ON_TRUE_RETURN_VAL(!size, NULL);
|
||||||
|
*size = 0;
|
||||||
|
return NULL;
|
||||||
|
(void)file;
|
||||||
|
(void)attribute;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI Eina_Bool
|
EAPI Eina_Bool
|
||||||
eina_xattr_set(const char *file, const char *attribute, const void *data, ssize_t length, Eina_Xattr_Flags flags)
|
eina_xattr_set(const char *file, const char *attribute, const void *data, ssize_t length, Eina_Xattr_Flags flags)
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_XATTR
|
||||||
int iflags;
|
int iflags;
|
||||||
|
|
||||||
EINA_SAFETY_ON_NULL_RETURN_VAL(file, EINA_FALSE);
|
EINA_SAFETY_ON_NULL_RETURN_VAL(file, EINA_FALSE);
|
||||||
|
@ -174,7 +182,6 @@ eina_xattr_set(const char *file, const char *attribute, const void *data, ssize_
|
||||||
EINA_SAFETY_ON_NULL_RETURN_VAL(data, EINA_FALSE);
|
EINA_SAFETY_ON_NULL_RETURN_VAL(data, EINA_FALSE);
|
||||||
EINA_SAFETY_ON_TRUE_RETURN_VAL(!(length > 0 && length < 2 * 1024 * 1024), EINA_FALSE);
|
EINA_SAFETY_ON_TRUE_RETURN_VAL(!(length > 0 && length < 2 * 1024 * 1024), EINA_FALSE);
|
||||||
|
|
||||||
#ifdef HAVE_XATTR
|
|
||||||
switch (flags)
|
switch (flags)
|
||||||
{
|
{
|
||||||
case EINA_XATTR_INSERT: iflags = 0; break;
|
case EINA_XATTR_INSERT: iflags = 0; break;
|
||||||
|
@ -189,6 +196,11 @@ eina_xattr_set(const char *file, const char *attribute, const void *data, ssize_
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
#else
|
#else
|
||||||
return EINA_FALSE;
|
return EINA_FALSE;
|
||||||
|
(void)file;
|
||||||
|
(void)attribute;
|
||||||
|
(void)data;
|
||||||
|
(void)length;
|
||||||
|
(void)flags;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue